From nobody Mon Feb 9 17:25:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1675351208; cv=none; d=zohomail.com; s=zohoarc; b=hjz//bv8ln8YojR0HPfRHNQ+X9PNQ/C15+Wip6PVgcMljoZ6J5Qg7C9UTDNCIMp3JHgDyYIVD2H0nbR95Y5AzqJzUcLUd0GHR6zGUmrat9ZisbAKW3+p+FNb6xPOipKrK4TnszpDUJJctKQnqbQhQ0Hnx6BPBDEMGF3STjdMu0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351208; 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=Gqsy8ue74tIF61fVh0SpqcantroKe5JUU2O/eQxPhlU=; b=ZDVjSd8BApvFJpqNb+uD/tX3sHgcMKWPNMie4oMlwcULrymdGjMIvr73xHiRIQ78d+mhLJwGQCVnA35p2n7JYnaD87JgAZGzPcou/MwBXxp588pTG3USPfZzilzqWl2uRs/mU2IxOToghCai5KW/5L9aGm9p5WAvTxcQGMGbUmI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1675351208595296.5560077702113; Thu, 2 Feb 2023 07:20:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-kRLiecfROxWOMWvlJZ94cA-1; Thu, 02 Feb 2023 10:19:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC19F800DA7; Thu, 2 Feb 2023 15:19:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6E6751FF; Thu, 2 Feb 2023 15:19:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 019201947356; Thu, 2 Feb 2023 15:18:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 07EEF1947345 for ; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F045B2026D2A; Thu, 2 Feb 2023 15:18:16 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4F82026D68 for ; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351207; 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=Gqsy8ue74tIF61fVh0SpqcantroKe5JUU2O/eQxPhlU=; b=iURLtYZsXpeDK8NHZQx7IuXH78UTKph6UvV3/qXCjsEeQkXbXmH/MkUZIo5GorONHBgroH 641JEeQ0tmiJh2NajV0GVSuEJOWlNbRrBUYrdKDSZc9wIvnyZ4vtfxf69GRnQeYegDUDnc IcphQUqAhn3OgzZ8aQaf7swliE6AmpI= X-MC-Unique: kRLiecfROxWOMWvlJZ94cA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] virBitmapIsBitSet: Allow NULL bitmap Date: Thu, 2 Feb 2023 16:18:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675351210563100006 Content-Type: text/plain; charset="utf-8" The virBitmapIsBitSet API is a permissive one which returns false when the bit is not set or is out of range. We can do the same if the bitmap is NULL to aid certain situations when this can happen, but we don't want to add extra checks. Signed-off-by: Peter Krempa --- src/util/virbitmap.c | 4 ++-- src/util/virbitmap.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 5b9204cbd7..bdcbd0aece 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -216,7 +216,7 @@ virBitmapIsSet(virBitmap *bitmap, size_t b) /** * virBitmapIsBitSet: - * @bitmap: Pointer to bitmap + * @bitmap: Pointer to bitmap (May be NULL) * @b: bit position to get * * Get setting of bit position @b in @bitmap. @@ -228,7 +228,7 @@ bool virBitmapIsBitSet(virBitmap *bitmap, size_t b) { - if (bitmap->nbits <=3D b) + if (!bitmap || bitmap->nbits <=3D b) return false; return virBitmapIsSet(bitmap, b); diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index e2314904b0..dbd88c9bb5 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -61,7 +61,7 @@ void virBitmapClearBitExpand(virBitmap *bitmap, size_t b) * Get bit @b in @bitmap. Returns false if b is out of range. */ bool virBitmapIsBitSet(virBitmap *bitmap, size_t b) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_WARN_UNUSED_RESULT; /* * Get setting of bit position @b in @bitmap and store in @result */ --=20 2.39.1