]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virBitmapFormat: Clarify returned values
authorPeter Krempa <pkrempa@redhat.com>
Mon, 17 Feb 2025 11:58:22 +0000 (12:58 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Feb 2025 14:15:39 +0000 (15:15 +0100)
NULL can't be returned; don't mention it in the docs.

Avoid extra cofusing variable when returning copy of empty string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virbitmap.c

index 138c1ac5afba15ab75e815eabe6b67ae43334407..e42f5b872c7dc64c2fca4889c0e7ab1f50ca6e29 100644 (file)
@@ -327,8 +327,8 @@ virBitmapToString(virBitmap *bitmap)
  *
  * 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.
+ * Returns the formatted string. Caller is responsible for freeing the returned
+ * string.
  */
 char *
 virBitmapFormat(virBitmap *bitmap)
@@ -337,11 +337,8 @@ virBitmapFormat(virBitmap *bitmap)
     bool first = true;
     int start, cur, prev;
 
-    if (!bitmap || (cur = virBitmapNextSetBit(bitmap, -1)) < 0) {
-        char *ret;
-        ret = g_strdup("");
-        return ret;
-    }
+    if (!bitmap || (cur = virBitmapNextSetBit(bitmap, -1)) < 0)
+        return g_strdup("");
 
     start = prev = cur;
     while (prev >= 0) {