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:
Ján Tomko committed 2014-06-06 14:35:18 +02:00
1 parent 8f3f51b723
commit cd09ab4db0
4 files changed
+6 -10

No files matched your search

+1 -2
View File
@@ -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,
+1 -1
View File
@@ -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)
+3 -5
View File
@@ -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;
+1 -2
View File
@@ -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,