mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
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:
parent
f55031535c
commit
51221af10e
@ -2492,7 +2492,6 @@ virJSONValueIsArray;
|
|||||||
virJSONValueIsNull;
|
virJSONValueIsNull;
|
||||||
virJSONValueIsObject;
|
virJSONValueIsObject;
|
||||||
virJSONValueNewArray;
|
virJSONValueNewArray;
|
||||||
virJSONValueNewArrayFromBitmap;
|
|
||||||
virJSONValueNewBoolean;
|
virJSONValueNewBoolean;
|
||||||
virJSONValueNewNull;
|
virJSONValueNewNull;
|
||||||
virJSONValueNewNumberDouble;
|
virJSONValueNewNumberDouble;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "virutil.h"
|
#include "virutil.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "virenum.h"
|
#include "virenum.h"
|
||||||
|
#include "virbitmap.h"
|
||||||
|
|
||||||
#if WITH_YAJL
|
#if WITH_YAJL
|
||||||
# include <yajl/yajl_gen.h>
|
# include <yajl/yajl_gen.h>
|
||||||
@ -304,7 +305,8 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||||||
case 'M':
|
case 'M':
|
||||||
case 'm': {
|
case 'm': {
|
||||||
virBitmapPtr map = va_arg(args, virBitmapPtr);
|
virBitmapPtr map = va_arg(args, virBitmapPtr);
|
||||||
g_autoptr(virJSONValue) jsonMap = NULL;
|
g_autoptr(virJSONValue) jsonMap = virJSONValueNewArray();
|
||||||
|
ssize_t pos = -1;
|
||||||
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
if (type == 'M')
|
if (type == 'M')
|
||||||
@ -316,8 +318,12 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(jsonMap = virJSONValueNewArrayFromBitmap(map)))
|
while ((pos = virBitmapNextSetBit(map, pos)) > -1) {
|
||||||
return -1;
|
g_autoptr(virJSONValue) newelem = virJSONValueNewNumberLong(pos);
|
||||||
|
|
||||||
|
if (virJSONValueArrayAppend(jsonMap, &newelem) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((rc = virJSONValueObjectAppend(obj, key, &jsonMap)) < 0)
|
if ((rc = virJSONValueObjectAppend(obj, key, &jsonMap)) < 0)
|
||||||
return -1;
|
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
|
bool
|
||||||
virJSONValueIsNull(virJSONValuePtr val)
|
virJSONValueIsNull(virJSONValuePtr val)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "virbitmap.h"
|
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -67,7 +66,6 @@ virJSONValuePtr virJSONValueNewBoolean(int boolean);
|
|||||||
virJSONValuePtr virJSONValueNewNull(void);
|
virJSONValuePtr virJSONValueNewNull(void);
|
||||||
virJSONValuePtr virJSONValueNewArray(void);
|
virJSONValuePtr virJSONValueNewArray(void);
|
||||||
virJSONValuePtr virJSONValueNewObject(void);
|
virJSONValuePtr virJSONValueNewObject(void);
|
||||||
virJSONValuePtr virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap);
|
|
||||||
|
|
||||||
int virJSONValueObjectAppend(virJSONValuePtr object,
|
int virJSONValueObjectAppend(virJSONValuePtr object,
|
||||||
const char *key,
|
const char *key,
|
||||||
|
Loading…
Reference in New Issue
Block a user