mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Format NULL bitmap as an empty string
This simplifies the usage in {libxl,qemu}DomainGetNumaParameters and it's needed for consistent error reporting in virBitmapFormat. Also remove the forgotten ATTRIBUTE_NONNULL marker.
This commit is contained in:
parent
8f3f51b723
commit
cd09ab4db0
@ -4002,8 +4002,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
nodeset = virBitmapFormat(nodes);
|
||||
if (!nodeset && VIR_STRDUP(nodeset, "") < 0)
|
||||
if (!(nodeset = virBitmapFormat(nodes)))
|
||||
goto cleanup;
|
||||
|
||||
if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_NODESET,
|
||||
|
@ -8914,7 +8914,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
|
||||
case 1: /* fill numa nodeset here */
|
||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||
nodeset = virBitmapFormat(persistentDef->numatune.memory.nodemask);
|
||||
if (!nodeset && VIR_STRDUP(nodeset, "") < 0)
|
||||
if (!nodeset)
|
||||
goto cleanup;
|
||||
} else {
|
||||
if (virCgroupGetCpusetMems(priv->cgroup, &nodeset) < 0)
|
||||
|
@ -218,6 +218,8 @@ char *virBitmapString(virBitmapPtr bitmap)
|
||||
*
|
||||
* See virBitmapParse for the format of @str.
|
||||
*
|
||||
* If bitmap is NULL or it has no bits set, an empty string is returned.
|
||||
*
|
||||
* Returns the string on success or NULL otherwise. Caller should call
|
||||
* VIR_FREE to free the string.
|
||||
*/
|
||||
@ -227,11 +229,7 @@ char *virBitmapFormat(virBitmapPtr bitmap)
|
||||
bool first = true;
|
||||
int start, cur, prev;
|
||||
|
||||
if (!bitmap)
|
||||
return NULL;
|
||||
|
||||
cur = virBitmapNextSetBit(bitmap, -1);
|
||||
if (cur < 0) {
|
||||
if (!bitmap || (cur = virBitmapNextSetBit(bitmap, -1)) < 0) {
|
||||
char *ret;
|
||||
ignore_value(VIR_STRDUP(ret, ""));
|
||||
return ret;
|
||||
|
@ -69,8 +69,7 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
|
||||
char *virBitmapString(virBitmapPtr bitmap)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
char *virBitmapFormat(virBitmapPtr bitmap)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
char *virBitmapFormat(virBitmapPtr bitmap);
|
||||
|
||||
int virBitmapParse(const char *str,
|
||||
char sep,
|
||||
|
Loading…
x
Reference in New Issue
Block a user