From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TR2I0-000558-Gd for qemu-devel@nongnu.org; Wed, 24 Oct 2012 10:50:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TR2Ht-0002u5-W6 for qemu-devel@nongnu.org; Wed, 24 Oct 2012 10:50:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TR2Ht-0002rZ-GJ for qemu-devel@nongnu.org; Wed, 24 Oct 2012 10:50:29 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9OEoPdv015070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Oct 2012 10:50:28 -0400 Message-ID: <5088002B.30402@redhat.com> Date: Wed, 24 Oct 2012 16:50:19 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1348675011-8794-1-git-send-email-pbonzini@redhat.com> <1348675011-8794-36-git-send-email-pbonzini@redhat.com> <5087FE1F.9090806@redhat.com> In-Reply-To: <5087FE1F.9090806@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 35/45] add hierarchical bitmap data type and test cases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: jcody@redhat.com, qemu-devel@nongnu.org Il 24/10/2012 16:41, Kevin Wolf ha scritto: >> +struct HBitmapIter { >> + const HBitmap *hb; >> + >> + /* Copied from hb for access in the inline functions (hb is opaque). */ >> + int granularity; >> + >> + /* Entry offset into the last-level array of longs. */ >> + size_t pos; > > Other places, for example HBitmap.size/count and the local pos variable > in hbitmap_iter_skip_words(), use uint64_t. Why is size_t here enough? size_t is enough if it is a word position. uint64_t is necessary if it is a bit position. This line of hbitmap_iter_next explains it well: item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ffsl(cur) - 1; Here the word position hbi->pos is converted to a bit position, so we need to convert size_t to uint64_t. In fact, hbitmap_iter_skip_words could indeed use a size_t. It uses uint64_t because the line above used to be in hbitmap_iter_skip_words, and used pos instead of hbi->pos. With that code, using uint64_t saved a cast. Paolo > >> + >> + /* The currently-active path in the tree. Each item of cur[i] stores >> + * the bits (i.e. the subtrees) yet to be processed under that node. >> + */ >> + unsigned long cur[HBITMAP_LEVELS]; >> +}; > > Kevin >