[libvirt PATCH 12/21] util: Use glib memory functions in virJSONValueGetArrayAsBitmap

Ján Tomko jtomko at redhat.com
Fri Sep 11 16:04:23 UTC 2020


On a Friday in 2020, Tim Wiederhake wrote:
>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> src/util/virjson.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/src/util/virjson.c b/src/util/virjson.c
>index 6921eccb60..6511b4e641 100644
>--- a/src/util/virjson.c
>+++ b/src/util/virjson.c
>@@ -1243,8 +1243,8 @@ virJSONValueGetArrayAsBitmap(const virJSONValue *val,
>     if (val->type != VIR_JSON_TYPE_ARRAY)
>         return -1;
>
>-    if (VIR_ALLOC_N_QUIET(elems, val->data.array.nvalues) < 0)
>-        return -1;
>+    /* elems might be NULL if val->data.array.nvalues is 0 */

Is this worthy of commenting? Even the calloc man page says this can
happen.

>+    elems = g_new0(unsigned long long, val->data.array.nvalues);
>
>     /* first pass converts array members to numbers and finds the maximum */
>     for (i = 0; i < val->data.array.nvalues; i++) {
>-- 
>2.26.2
>

Without the comment:
Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200911/e6f184e0/attachment-0001.sig>


More information about the libvir-list mailing list