From nobody Mon Feb 9 01:22:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601624632; cv=none; d=zohomail.com; s=zohoarc; b=NsmH6w02lmcWIK4L3NNeJMwz4M29mXQm/4kCJSlzQb9/Yc65rR3GajH2rK8km7E2Sj7wsL60usjd5GlE8fXCuqbbRPx2BsyJaDHIb/M+j2n3b5E7qp0lhnEtfojQA6yb33gcEiO7HoMa8pdp2PqzMTx6Bhgygmrk6CyufpLMm8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601624632; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q3aB6dqWXotKucMTe1xpCCCpxZTRD6slr/XxkTVfCRg=; b=DoEh8aJKXvE1taNtdG+B164zpZQY0cdD3To+ItfAEvaKlUhKMC7IM38tXAwVRMdpGGSyefcIebjSTpEZOp4thd5utappfrTBIQb5uclzGQ/Y7PIgrNYyC0qr8ZMV8cU05KA00654Tf5A1Y1vTexx/5+j1fv1lQIs3ZajeZlkquo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601624632284988.2790423125473; Fri, 2 Oct 2020 00:43:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-W_JQaKt8PqaES3YpdHPrzw-1; Fri, 02 Oct 2020 03:43:49 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03CB4101FFAE; Fri, 2 Oct 2020 07:43:42 +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 D42D25D9E4; Fri, 2 Oct 2020 07:43:41 +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 A0AB944A6A; Fri, 2 Oct 2020 07:43:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0927hNEI004181 for ; Fri, 2 Oct 2020 03:43:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id E84251972A; Fri, 2 Oct 2020 07:43:23 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E6BD1992F for ; Fri, 2 Oct 2020 07:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601624631; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Q3aB6dqWXotKucMTe1xpCCCpxZTRD6slr/XxkTVfCRg=; b=JGDeu6HcO8YKjPM07z98bAG8KOeGxLpRPD14P0wU17jboOVFn+5B/EeMqSWcbvK/Ywi0da A70LH+V5vViZHauHe7YYwvCkOOmN6CnyK1zgP4aYwFgGedHnQFhxawVHCP/mHJLfZ3Vk4I gYFRYltnhWP4eCtL4vPdtSY+7Dx0jDM= X-MC-Unique: W_JQaKt8PqaES3YpdHPrzw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/15] util: virbitmap: Don't forbid 0 size bitmap Date: Fri, 2 Oct 2020 09:43:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We now have APIs which automatically expand the bitmap and also API which allocates a 0 size bitmap. Remove the condition from virBitmapNew. Effectively reverts ce49cfb48ad Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virbitmap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index f1443c3ecf..5df7ea7838 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -55,8 +55,8 @@ struct _virBitmap { * * Allocate a bitmap capable of containing @size bits. * - * Returns a pointer to the allocated bitmap or NULL if either memory cann= ot be - * allocated or size is 0. Does not report libvirt errors. + * Returns a pointer to the allocated bitmap or NULL if memory cannot be + * allocated. Does not report libvirt errors. */ virBitmapPtr virBitmapNewQuiet(size_t size) @@ -64,12 +64,16 @@ virBitmapNewQuiet(size_t size) virBitmapPtr bitmap; size_t sz; - if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size =3D=3D 0) + if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size) return NULL; sz =3D VIR_DIV_UP(size, VIR_BITMAP_BITS_PER_UNIT); bitmap =3D g_new0(virBitmap, 1); + + if (size =3D=3D 0) + return bitmap; + bitmap->map =3D g_new0(unsigned long, sz); bitmap->nbits =3D size; bitmap->map_len =3D sz; --=20 2.26.2