From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwZDr-0002rU-69 for qemu-devel@nongnu.org; Tue, 18 Oct 2016 14:34:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwZDm-0006PA-9O for qemu-devel@nongnu.org; Tue, 18 Oct 2016 14:34:47 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:58164) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwZDm-0006Ow-4k for qemu-devel@nongnu.org; Tue, 18 Oct 2016 14:34:42 -0400 Date: Tue, 18 Oct 2016 14:34:41 -0400 From: "Emilio G. Cota" Message-ID: <20161018183441.GB9586@flamenco> References: <20161018145620.20658-1-bobby.prani@gmail.com> <20161018145620.20658-2-bobby.prani@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161018145620.20658-2-bobby.prani@gmail.com> Subject: Re: [Qemu-devel] [PATCH 2/2] translate-all: Use proper type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pranith Kumar Cc: Paolo Bonzini , Peter Crosthwaite , Richard Henderson , "open list:Overall" On Tue, Oct 18, 2016 at 10:56:20 -0400, Pranith Kumar wrote: > gcc does not warn about the wrong type since it is a void pointer > which can be cast to any type. > > Signed-off-by: Pranith Kumar > --- > translate-all.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/translate-all.c b/translate-all.c > index 8ca393c..c77470a 100644 > --- a/translate-all.c > +++ b/translate-all.c > @@ -412,7 +412,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) > > /* Level 2..N-1. */ > for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) { > - void **p = atomic_rcu_read(lp); > + void *p = atomic_rcu_read(lp); > > if (p == NULL) { > if (!alloc) { Let me redo your patch with more context (for patches like this using format-patch -U is useful): $ git diff -U11 translate-all.c diff --git a/translate-all.c b/translate-all.c index 4200869..6928ace 100644 --- a/translate-all.c +++ b/translate-all.c @@ -405,23 +405,23 @@ static void page_init(void) static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) { PageDesc *pd; void **lp; int i; /* Level 1. Always allocated. */ lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1)); /* Level 2..N-1. */ for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) { - void **p = atomic_rcu_read(lp); + void *p = atomic_rcu_read(lp); if (p == NULL) { if (!alloc) { return NULL; } p = g_new0(void *, V_L2_SIZE); atomic_rcu_set(lp, p); } lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1)); } I prefer void **p since that matches lp's and l1_map's type. It's true that since we're dealing with void * the compiler won't complain either way. Emilio