util: json: Remove virJSONValueNewArrayFromBitmap

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@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-08 13:42:30 +02:00
parent f55031535c
commit 51221af10e
3 changed files with 9 additions and 26 deletions

View File

@ -2492,7 +2492,6 @@ virJSONValueIsArray;
virJSONValueIsNull;
virJSONValueIsObject;
virJSONValueNewArray;
virJSONValueNewArrayFromBitmap;
virJSONValueNewBoolean;
virJSONValueNewNull;
virJSONValueNewNumberDouble;

View File

@ -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)
{

View File

@ -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,