virBitmapToString: Remove unused 'prefix' and 'trim' arguments

There's only one combination used so we can remove the rest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-10-01 15:22:24 +02:00
parent c00ab99f16
commit 8efad320fa
4 changed files with 4 additions and 17 deletions

View File

@ -327,17 +327,13 @@ virBitmapGetBit(virBitmapPtr bitmap,
/**
* virBitmapToString:
* @bitmap: Pointer to bitmap
* @prefix: Whether to prepend "0x"
* @trim: Whether to output only the minimum required characters
*
* Convert @bitmap to printable string.
*
* Returns pointer to the string or NULL on error.
*/
char *
virBitmapToString(virBitmapPtr bitmap,
bool prefix,
bool trim)
virBitmapToString(virBitmapPtr bitmap)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t sz;
@ -345,9 +341,6 @@ virBitmapToString(virBitmapPtr bitmap,
size_t diff;
char *ret = NULL;
if (prefix)
virBufferAddLit(&buf, "0x");
sz = bitmap->map_len;
while (sz--) {
@ -360,15 +353,9 @@ virBitmapToString(virBitmapPtr bitmap,
if (!ret)
return NULL;
if (!trim)
return ret;
if (bitmap->nbits != bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT) {
char *tmp = ret;
if (prefix)
tmp += 2;
len = strlen(tmp);
sz = VIR_DIV_UP(bitmap->nbits, 4);
diff = len - sz;

View File

@ -81,7 +81,7 @@ virBitmapPtr
virBitmapNewString(const char *string)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
char *virBitmapToString(virBitmapPtr bitmap, bool prefix, bool trim)
char *virBitmapToString(virBitmapPtr bitmap)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
char *virBitmapFormat(virBitmapPtr bitmap);

View File

@ -1592,7 +1592,7 @@ virResctrlAllocFormatCache(virResctrlAllocPtr alloc,
if (!mask)
continue;
mask_str = virBitmapToString(mask, false, true);
mask_str = virBitmapToString(mask);
if (!mask_str)
return -1;

View File

@ -681,7 +681,7 @@ test13(const void *opaque G_GNUC_UNUSED)
if (!map)
goto cleanup;
str = virBitmapToString(map, false, true);
str = virBitmapToString(map);
if (!str)
goto cleanup;