[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: |
Marin Ramesa |
Subject: |
Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable |
Date: |
Wed, 18 Dec 2013 11:25:36 +0100 |
On 18.12.2013 11:11:10, Richard Braun wrote:
> The expression is ((a == NULL) || a->something), and I agree it is
> equivalent to !((a != NULL) && !a->something). And again, both the
> && and || operators are guaranteed to be evaluated left-to-right and
> *yield* without evaluating the second operand if the first compares
> or not to 0, depending on the operator.
>
> So, let's take the seconds form since that's what you've used,
> without the negation for simplicity : ((a != NULL) && !a->something)
>
> If a isn't NULL, then it returns !a->something. If a is NULL, then
> (a != NULL) compares equal to 0, and && returns 0 before evaluating
> !a->something. So no, there can't be a null pointer dereference here.
>
> And this really is basic C, so please double check your changes.
Yes, vou're right. I got confused. But then something else is happening
here. When I write the assertion this way:
assert((entry == IE_NULL) || ((entry != IE_NULL) ? IE_BITS_TYPE
(entry->ie_bits) : TRUE));
GCC stops complaing about uninitialized variable.
- Re: [PATCH 2/3] ipc/mach_debug.c (host_ipc_hash_info): quiet GCC warning about uninitialized variable, (continued)
- [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, 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, 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 <=
- 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