From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF5jK-0007hZ-6R for qemu-devel@nongnu.org; Wed, 27 Apr 2011 10:28:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QF5jC-0006j0-3X for qemu-devel@nongnu.org; Wed, 27 Apr 2011 10:28:38 -0400 Received: from hall.aurel32.net ([88.191.126.93]:41917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF5jB-0006it-R0 for qemu-devel@nongnu.org; Wed, 27 Apr 2011 10:28:30 -0400 Date: Wed, 27 Apr 2011 16:28:27 +0200 From: Aurelien Jarno Message-ID: <20110427142827.GC31605@volta.aurel32.net> References: <1301847765-8203-1-git-send-email-weil@mail.berlios.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1301847765-8203-1-git-send-email-weil@mail.berlios.de> Subject: Re: [Qemu-devel] [PATCH] darwin-user: Remove unneeded null pointer check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Blue Swirl , QEMU Developers On Sun, Apr 03, 2011 at 06:22:45PM +0200, Stefan Weil wrote: > cppcheck reports this error: > > commpage.c:223: error: Possible null pointer dereference: > value - otherwise it is redundant to check if value is null at line 214 > > The null pointer check in line 214 is indeed not needed. > If value were null, the code would crash in line 223. > See do_compare_and_swap64 were for a reference. > > Signed-off-by: Stefan Weil > --- > darwin-user/commpage.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) Thanks, applied. > diff --git a/darwin-user/commpage.c b/darwin-user/commpage.c > index f6aa71e..cc29bdd 100644 > --- a/darwin-user/commpage.c > +++ b/darwin-user/commpage.c > @@ -211,7 +211,7 @@ void do_compare_and_swap32(void *cpu_env, int num) > uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX]; > DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value); > > - if(value && old == tswap32(*value)) > + if(old == tswap32(*value)) > { > uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX]; > *value = tswap32(new); > -- > 1.7.2.5 > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net