From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RphrX-0001MY-JP for qemu-devel@nongnu.org; Tue, 24 Jan 2012 10:00:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RphrJ-0004tz-7z for qemu-devel@nongnu.org; Tue, 24 Jan 2012 10:00:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RphrI-0004tX-PY for qemu-devel@nongnu.org; Tue, 24 Jan 2012 10:00:29 -0500 Message-ID: <4F1EC854.30409@redhat.com> Date: Tue, 24 Jan 2012 16:03:48 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1326898793-20331-1-git-send-email-stefanha@linux.vnet.ibm.com> <1326898793-20331-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1326898793-20331-2-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 1/6] cutils: extract buffer_is_zero() from qemu-img.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org Am 18.01.2012 15:59, schrieb Stefan Hajnoczi: > The qemu-img.c:is_not_zero() function checks if a buffer contains all > zeroes. This function will come in handy for zero-detection in the > block layer, so clean it up and move it to cutils.c. > > Note that the function now returns true if the buffer is all zeroes. > This avoids the double-negatives (i.e. !is_not_zero()) that the old > function can cause in callers. > > Signed-off-by: Stefan Hajnoczi > --- > cutils.c | 34 ++++++++++++++++++++++++++++++++++ > qemu-common.h | 2 ++ > qemu-img.c | 46 +++++++--------------------------------------- > 3 files changed, 43 insertions(+), 39 deletions(-) > > diff --git a/cutils.c b/cutils.c > index a6ffd46..2ea9c3c 100644 > --- a/cutils.c > +++ b/cutils.c > @@ -303,6 +303,40 @@ void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count, > } > } > > +/* > + * Checks if a buffer is all zeroes > + * > + * Attention! The len must be a multiple of 4 * sizeof(long) due to > + * restriction of optimizations in this function. > + */ Sounds like something to assert(), while you're touching the code. Kevin