From nobody Mon Feb 9 08:29:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1570785147; cv=none; d=zoho.com; s=zohoarc; b=fZoDLswhDvzr5aBaqrZ3qhPuv35A9hwEK+rfURFtrGm9dcq87fjouZ+YGtLWeHzN+T4XkcKzjvCbGyA4aw10E/ChT7d9crS1K0rujATDlGQTguOcIVNfEZBF6Vs2UeA++SQ8iW7GELyDW5jQoDUlLIKwNqqj5tIVDbfzafjoSfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570785147; h=Content-Transfer-Encoding:Cc: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=tEBCvdtdPkp/eY9CCifTXfvg5M8b9KjaBcV1UpUmMBA=; b=OA+9oolNrmrUm+UupIMl69gnk5h3LXbjVHBgUi098V23XgOqLEHNC1hWjj0SIQKgvQENIPNSzxWNRxWRphcmKivm+MlbvdIfFvs7/DGYq4wYg42VBf1f4i4ocII7TgvnSr3FQ2/AZMVv7bsg4DHcSnqpgKABkUzpCDyEu3mHduk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570785147577453.03330538494413; Fri, 11 Oct 2019 02:12:27 -0700 (PDT) Received: from localhost ([::1]:47642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIqyI-0004az-Dn for importer@patchew.org; Fri, 11 Oct 2019 05:12:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49509) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIqtM-0005we-57 for qemu-devel@nongnu.org; Fri, 11 Oct 2019 05:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIqtL-0004BC-5P for qemu-devel@nongnu.org; Fri, 11 Oct 2019 05:07:20 -0400 Received: from relay.sw.ru ([185.231.240.75]:60310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIqtH-000476-OP; Fri, 11 Oct 2019 05:07:15 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iIqtD-0000XM-Vc; Fri, 11 Oct 2019 12:07:12 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v2 1/5] hbitmap: handle set/reset with zero length Date: Fri, 11 Oct 2019 12:07:07 +0300 Message-Id: <20191011090711.19940-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191011090711.19940-1-vsementsov@virtuozzo.com> References: <20191011090711.19940-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Passing zero length to these functions leads to unpredicted results. Zero-length set/reset may occur in active-mirror, on zero-length write (which is unlikely, but not guaranteed to never happen). Let's just do nothing on zero-length request. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- util/hbitmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/hbitmap.c b/util/hbitmap.c index fd44c897ab..86b0231046 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -387,6 +387,10 @@ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t= count) uint64_t first, n; uint64_t last =3D start + count - 1; =20 + if (count =3D=3D 0) { + return; + } + trace_hbitmap_set(hb, start, count, start >> hb->granularity, last >> hb->granularity); =20 @@ -477,6 +481,10 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64= _t count) uint64_t first; uint64_t last =3D start + count - 1; =20 + if (count =3D=3D 0) { + return; + } + trace_hbitmap_reset(hb, start, count, start >> hb->granularity, last >> hb->granularity); =20 --=20 2.21.0