From: Aurelien Jarno <aurelien@aurel32.net>
To: Stefan Weil <weil@mail.berlios.de>
Cc: Blue Swirl <blauwirbel@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] darwin-user: Remove unneeded null pointer check
Date: Wed, 27 Apr 2011 16:28:27 +0200 [thread overview]
Message-ID: <20110427142827.GC31605@volta.aurel32.net> (raw)
In-Reply-To: <1301847765-8203-1-git-send-email-weil@mail.berlios.de>
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 <weil@mail.berlios.de>
> ---
> 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
prev parent reply other threads:[~2011-04-27 14:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-03 16:22 [Qemu-devel] [PATCH] darwin-user: Remove unneeded null pointer check Stefan Weil
2011-04-27 14:28 ` Aurelien Jarno [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110427142827.GC31605@volta.aurel32.net \
--to=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).