From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adaRs-0008R0-Ew for qemu-devel@nongnu.org; Wed, 09 Mar 2016 04:30:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adaRk-0004us-Vb for qemu-devel@nongnu.org; Wed, 09 Mar 2016 04:30:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adaRk-0004um-Pt for qemu-devel@nongnu.org; Wed, 09 Mar 2016 04:30:24 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 729B663151 for ; Wed, 9 Mar 2016 09:30:24 +0000 (UTC) References: <1457503932-31763-1-git-send-email-peterx@redhat.com> <56DFD6CB.90906@redhat.com> <20160309082606.GS2377@pxdev.xzpeter.org> From: Paolo Bonzini Message-ID: <56DFED2C.2080507@redhat.com> Date: Wed, 9 Mar 2016 10:30:20 +0100 MIME-Version: 1.0 In-Reply-To: <20160309082606.GS2377@pxdev.xzpeter.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Peter Xu Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com On 09/03/2016 09:26, Peter Xu wrote: >>> > > 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? Oops, I was wrong. It's related to how header_len is used. header_len here is clearly a size in bytes (it's passed to qemu_get_buffer), so the patch is okay. Paolo > Anyway, I take my above question as trivial since current buffer is > char typed.