The function is used only inside of the file. We can open-code it and remove it as it's not very useful. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/libvirt_private.syms | 1 - src/util/virjson.c | 32 +++++++++----------------------- src/util/virjson.h | 2 -- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0801728a74..fd2d4462a6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2492,7 +2492,6 @@ virJSONValueIsArray; virJSONValueIsNull; virJSONValueIsObject; virJSONValueNewArray; -virJSONValueNewArrayFromBitmap; virJSONValueNewBoolean; virJSONValueNewNull; virJSONValueNewNumberDouble; diff --git a/src/util/virjson.c b/src/util/virjson.c index 746386c619..0eff467ec5 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -31,6 +31,7 @@ #include "virutil.h" #include "virbuffer.h" #include "virenum.h" +#include "virbitmap.h" #if WITH_YAJL # include <yajl/yajl_gen.h> @@ -304,7 +305,8 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj, case 'M': case 'm': { virBitmapPtr map = va_arg(args, virBitmapPtr); - g_autoptr(virJSONValue) jsonMap = NULL; + g_autoptr(virJSONValue) jsonMap = virJSONValueNewArray(); + ssize_t pos = -1; if (!map) { if (type == 'M') @@ -316,8 +318,12 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj, return -1; } - if (!(jsonMap = virJSONValueNewArrayFromBitmap(map))) - return -1; + while ((pos = virBitmapNextSetBit(map, pos)) > -1) { + g_autoptr(virJSONValue) newelem = virJSONValueNewNumberLong(pos); + + if (virJSONValueArrayAppend(jsonMap, &newelem) < 0) + return -1; + } if ((rc = virJSONValueObjectAppend(obj, key, &jsonMap)) < 0) return -1; @@ -1174,26 +1180,6 @@ virJSONValueGetBoolean(virJSONValuePtr val, } -virJSONValuePtr -virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap) -{ - g_autoptr(virJSONValue) ret = virJSONValueNewArray(); - ssize_t pos = -1; - - if (!bitmap) - return g_steal_pointer(&ret); - - while ((pos = virBitmapNextSetBit(bitmap, pos)) > -1) { - g_autoptr(virJSONValue) newelem = virJSONValueNewNumberLong(pos); - - if (virJSONValueArrayAppend(ret, &newelem) < 0) - return NULL; - } - - return g_steal_pointer(&ret); -} - - bool virJSONValueIsNull(virJSONValuePtr val) { diff --git a/src/util/virjson.h b/src/util/virjson.h index 1f15b23233..3197f81f86 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -23,7 +23,6 @@ #pragma once #include "internal.h" -#include "virbitmap.h" #include "virbuffer.h" #include <stdarg.h> @@ -67,7 +66,6 @@ virJSONValuePtr virJSONValueNewBoolean(int boolean); virJSONValuePtr virJSONValueNewNull(void); virJSONValuePtr virJSONValueNewArray(void); virJSONValuePtr virJSONValueNewObject(void); -virJSONValuePtr virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap); int virJSONValueObjectAppend(virJSONValuePtr object, const char *key, -- 2.30.2