[libvirt] [PATCH v1 01/37] viralloc: Report OOM error on failure

Laine Stump laine at laine.org
Fri Jul 5 03:51:55 UTC 2013


On 07/04/2013 08:06 AM, Michal Privoznik wrote:
>  virInsertElementsN(void *ptrptr, size_t size, size_t at,
>                     size_t *countptr,
>                     size_t add, void *newelems,
> -                   bool clearOriginal, bool inPlace)
> +                   bool clearOriginal, bool inPlace,
> +                   bool report,
> +                   int domcode,
> +                   const char *filename,
> +                   const char *funcname,
> +                   size_t linenr)
>  {
>      if (at == -1) {
>          at = *countptr;
>      } else if (at > *countptr) {
> -        VIR_WARN("out of bounds index - count %zu at %zu add %zu",
> -                 *countptr, at, add);
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("out of bounds index - count %zu at %zu add %zu"),
> +                       *countptr, at, add);
>          return -1;

If this happens and "report" is set to True, the caller will also report
the error (but as OOM), overwriting this one.

I don't really have a suggestion for a better way to handle it, just
thought I'd point it out (that's why it was a VIR_WARN, but in the end
that's really no better, since again the error code in the API would
come from the caller, and in both cases the system logs would contain
both the "out of bounds" message and the "out of memory" message).





More information about the libvir-list mailing list