darwin-user: Remove unneeded null pointer check
authorStefan Weil <weil@mail.berlios.de>
Sun, 3 Apr 2011 16:22:45 +0000 (18:22 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Wed, 27 Apr 2011 14:28:09 +0000 (16:28 +0200)
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 <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
darwin-user/commpage.c

index f6aa71e..cc29bdd 100644 (file)
@@ -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);