[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC
From: |
Richard Braun |
Subject: |
Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable |
Date: |
Wed, 18 Dec 2013 10:48:19 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Dec 18, 2013 at 10:46:40AM +0100, Richard Braun wrote:
> On Wed, Dec 18, 2013 at 10:37:03AM +0100, Marin Ramesa wrote:
> > Compiler needs to check both !a and !b. In order to evaluate !b it must
> > evaluate b. So when the code path is that when entry is a null pointer,
> > the evaluation of b results in a dereference of a null pointer.
>
> No, that's wrong. The && and || operators are guaranteed to be evaluated
> left-to-right, and yield if the first operand compares equal to 0. And
> that's exactly why this check against NULL is done first.
Compares equal to 0 for &&, and not equal to 0 for ||, obviously.
--
Richard Braun
- [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- [PATCH 2/3] ipc/mach_debug.c (host_ipc_hash_info): quiet GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- [PATCH 3/3] vm/vm_debug.c: quiet GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Anatoly A. Kazantsev, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Richard Braun, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable,
Richard Braun <=
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Richard Braun, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Richard Braun, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Richard Braun, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Marin Ramesa, 2013/12/18
- Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable, Ivan Shmakov, 2013/12/18