From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adZRo-00078C-Hq for qemu-devel@nongnu.org; Wed, 09 Mar 2016 03:26:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adZRj-0005VA-IO for qemu-devel@nongnu.org; Wed, 09 Mar 2016 03:26:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adZRj-0005Uy-Dg for qemu-devel@nongnu.org; Wed, 09 Mar 2016 03:26:19 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 08B658EA41 for ; Wed, 9 Mar 2016 08:26:19 +0000 (UTC) Date: Wed, 9 Mar 2016 16:26:06 +0800 From: Peter Xu Message-ID: <20160309082606.GS2377@pxdev.xzpeter.org> References: <1457503932-31763-1-git-send-email-peterx@redhat.com> <56DFD6CB.90906@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56DFD6CB.90906@redhat.com> Subject: Re: [Qemu-devel] [PATCH] migration: fix warning for source_return_path_thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com On Wed, Mar 09, 2016 at 08:54:51AM +0100, Paolo Bonzini wrote: > > @@ -1292,7 +1291,7 @@ static void *source_return_path_thread(void *opaque) > > > > if ((rp_cmd_args[header_type].len != -1 && > > header_len != rp_cmd_args[header_type].len) || > > - header_len > max_len) { > > + header_len > sizeof(buf)) { > > sizeof works fine because buf is an array of bytes, but ARRAY_SIZE is > better because it works for any type of buffer. I carefully chose "sizeof" out of "ARRAY_SIZE" as commented by Eric that, we'd better use sizeof() for char typed buffers. Will this be related to how header_len is defined? That's something I do not know... :( E.g., if it's defined as "length in bytes", then shall we better use sizeof() in all cases? Anyway, I take my above question as trivial since current buffer is char typed. Thanks! Peter