From nobody Mon Feb 9 06:48:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517836713480584.6721324396283; Mon, 5 Feb 2018 05:18:33 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 954AC28203; Mon, 5 Feb 2018 13:18:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 684FC18BAA; Mon, 5 Feb 2018 13:18:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2BF1241FAE; Mon, 5 Feb 2018 13:18:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w15DIV5O032742 for ; Mon, 5 Feb 2018 08:18:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id B37FF18BA8; Mon, 5 Feb 2018 13:18:31 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10EAC659EC; Mon, 5 Feb 2018 13:18:28 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 5 Feb 2018 14:17:42 +0100 Message-Id: <7ae883863e7d20aef8d2e3bde6350a45a7612518.1517836057.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/6] util: bitmap: Rename 'max_bit' to 'nbits' X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Feb 2018 13:18:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 'max_bit' is misleading as the value is set to the first invalid bit as it's used as the number of bits in the bitmap. Rename it to a more descriptive name. --- src/util/virbitmap.c | 54 ++++++++++++++++++++++++++----------------------= ---- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 33cae2f305..c1b97d90fb 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -42,7 +42,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE struct _virBitmap { - size_t max_bit; + size_t nbits; size_t map_len; size_t map_alloc; unsigned long *map; @@ -83,7 +83,7 @@ virBitmapNewQuiet(size_t size) return NULL; } - bitmap->max_bit =3D size; + bitmap->nbits =3D size; bitmap->map_len =3D sz; bitmap->map_alloc =3D sz; return bitmap; @@ -147,7 +147,7 @@ void virBitmapFree(virBitmapPtr bitmap) int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src) { - if (dst->max_bit !=3D src->max_bit) { + if (dst->nbits !=3D src->nbits) { errno =3D EINVAL; return -1; } @@ -169,7 +169,7 @@ int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src) */ int virBitmapSetBit(virBitmapPtr bitmap, size_t b) { - if (bitmap->max_bit <=3D b) + if (bitmap->nbits <=3D b) return -1; bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] |=3D VIR_BITMAP_BIT(b); @@ -197,7 +197,7 @@ static int virBitmapExpand(virBitmapPtr map, size_t b) return -1; } - map->max_bit =3D b + 1; + map->nbits =3D b + 1; map->map_len =3D new_len; return 0; @@ -216,7 +216,7 @@ static int virBitmapExpand(virBitmapPtr map, size_t b) */ int virBitmapSetBitExpand(virBitmapPtr bitmap, size_t b) { - if (bitmap->max_bit <=3D b && virBitmapExpand(bitmap, b) < 0) + if (bitmap->nbits <=3D b && virBitmapExpand(bitmap, b) < 0) return -1; bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] |=3D VIR_BITMAP_BIT(b); @@ -235,7 +235,7 @@ int virBitmapSetBitExpand(virBitmapPtr bitmap, size_t b) */ int virBitmapClearBit(virBitmapPtr bitmap, size_t b) { - if (bitmap->max_bit <=3D b) + if (bitmap->nbits <=3D b) return -1; bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] &=3D ~VIR_BITMAP_BIT(b); @@ -255,7 +255,7 @@ int virBitmapClearBit(virBitmapPtr bitmap, size_t b) */ int virBitmapClearBitExpand(virBitmapPtr bitmap, size_t b) { - if (bitmap->max_bit <=3D b) { + if (bitmap->nbits <=3D b) { if (virBitmapExpand(bitmap, b) < 0) return -1; } else { @@ -266,7 +266,7 @@ int virBitmapClearBitExpand(virBitmapPtr bitmap, size_t= b) } -/* Helper function. caller must ensure b < bitmap->max_bit */ +/* Helper function. caller must ensure b < bitmap->nbits */ static bool virBitmapIsSet(virBitmapPtr bitmap, size_t b) { return !!(bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] & VIR_BITMAP_BIT(b)); @@ -284,7 +284,7 @@ static bool virBitmapIsSet(virBitmapPtr bitmap, size_t = b) */ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b) { - if (bitmap->max_bit <=3D b) + if (bitmap->nbits <=3D b) return false; return virBitmapIsSet(bitmap, b); @@ -303,7 +303,7 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b) */ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result) { - if (bitmap->max_bit <=3D b) + if (bitmap->nbits <=3D b) return -1; *result =3D virBitmapIsSet(bitmap, b); @@ -350,14 +350,14 @@ virBitmapToString(virBitmapPtr bitmap, if (!trim) return ret; - if (bitmap->max_bit !=3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT) { + if (bitmap->nbits !=3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT) { char *tmp =3D ret; if (prefix) tmp +=3D 2; len =3D strlen(tmp); - sz =3D VIR_DIV_UP(bitmap->max_bit, 4); + sz =3D VIR_DIV_UP(bitmap->nbits, 4); diff =3D len - sz; if (diff) @@ -692,7 +692,7 @@ virBitmapPtr virBitmapNewCopy(virBitmapPtr src) { virBitmapPtr dst; - if ((dst =3D virBitmapNew(src->max_bit)) =3D=3D NULL) + if ((dst =3D virBitmapNew(src->nbits)) =3D=3D NULL) return NULL; if (virBitmapCopy(dst, src) !=3D 0) { @@ -818,7 +818,7 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2) if (!b1 || !b2) return false; - if (b1->max_bit > b2->max_bit) { + if (b1->nbits > b2->nbits) { tmp =3D b1; b1 =3D b2; b2 =3D tmp; @@ -841,7 +841,7 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2) size_t virBitmapSize(virBitmapPtr bitmap) { - return bitmap->max_bit; + return bitmap->nbits; } /** @@ -852,7 +852,7 @@ size_t virBitmapSize(virBitmapPtr bitmap) */ void virBitmapSetAll(virBitmapPtr bitmap) { - int tail =3D bitmap->max_bit % VIR_BITMAP_BITS_PER_UNIT; + int tail =3D bitmap->nbits % VIR_BITMAP_BITS_PER_UNIT; memset(bitmap->map, 0xff, bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_BIT)); @@ -887,7 +887,7 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap) int unusedBits; size_t sz; - unusedBits =3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap->ma= x_bit; + unusedBits =3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap->nb= its; sz =3D bitmap->map_len; if (unusedBits > 0) @@ -946,7 +946,7 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos) pos++; - if (pos >=3D bitmap->max_bit) + if (pos >=3D bitmap->nbits) return -1; nl =3D pos / VIR_BITMAP_BITS_PER_UNIT; @@ -983,7 +983,7 @@ virBitmapLastSetBit(virBitmapPtr bitmap) if (bitmap->map_len =3D=3D 0) return -1; - unusedBits =3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap->ma= x_bit; + unusedBits =3D bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap->nb= its; sz =3D bitmap->map_len - 1; if (unusedBits > 0) { @@ -1035,7 +1035,7 @@ virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t po= s) pos++; - if (pos >=3D bitmap->max_bit) + if (pos >=3D bitmap->nbits) return -1; nl =3D pos / VIR_BITMAP_BITS_PER_UNIT; @@ -1048,7 +1048,7 @@ virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t po= s) if (nl =3D=3D bitmap->map_len - 1) { /* Ensure tail bits are ignored. */ - int tail =3D bitmap->max_bit % VIR_BITMAP_BITS_PER_UNIT; + int tail =3D bitmap->nbits % VIR_BITMAP_BITS_PER_UNIT; if (tail) bits &=3D -1UL >> (VIR_BITMAP_BITS_PER_UNIT - tail); @@ -1140,7 +1140,7 @@ virBitmapOverlaps(virBitmapPtr b1, { size_t i; - if (b1->max_bit > b2->max_bit) { + if (b1->nbits > b2->nbits) { virBitmapPtr tmp =3D b1; b1 =3D b2; b2 =3D tmp; @@ -1216,11 +1216,11 @@ virBitmapShrink(virBitmapPtr map, if (!map) return 0; - if (map->max_bit >=3D b) - map->max_bit =3D b; + if (map->nbits >=3D b) + map->nbits =3D b; - nl =3D map->max_bit / VIR_BITMAP_BITS_PER_UNIT; - nb =3D map->max_bit % VIR_BITMAP_BITS_PER_UNIT; + nl =3D map->nbits / VIR_BITMAP_BITS_PER_UNIT; + nb =3D map->nbits % VIR_BITMAP_BITS_PER_UNIT; map->map[nl] &=3D ((1UL << nb) - 1); nl++; --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list