From 13c54c89451596f77d0dbe4b58876d005a08850b Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 17 Feb 2025 12:58:22 +0100 Subject: [PATCH] virBitmapFormat: Clarify returned values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/util/virbitmap.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 138c1ac5af..e42f5b872c 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -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) { -- 2.47.3