Re: net: rnpgbe: Pass an expression directly in rnpgbe_rm_adapter()

From
Dan Carpenter <hidden>
Date
2026-07-16 09:30:56
Also in
kernel-janitors, lkml
Reply to
Markus Elfring, 2026-07-15
On Wed, Jul 15, 2026 at 08:45:48PM +0200, Markus Elfring wrote:
Jonathan Corbet provided the following information.

“…
But Herbert's patch added a line which dereferences the pointer prior to the check. That, of course, is a bug.
…”
Notice that it says "dereferences" not "does pointer math".
quoted
                                                      Note, I didn't
study the C standard
I hope that clarification approaches can evolve further according to this information source.

quoted
                     if the compiler is free to optimize out
do_something() also in the 2nd case, but at least today gcc doesn't.
Can development interests grow also according to another clarification approach?

Does &((struct name *)NULL -> b) cause undefined behaviour in C11?
https://stackoverflow.com/questions/26906621/does-struct-name-null-b-cause-undefined-behaviour-in-c11



Would you prefer to omit a “sanity check” in the discussed function implementation?
This is irrelevant.

In C writing if (!p) and if (p == NULL) are always equivalent but weirdly
the NULL doesn't have to zero.  It's part of the C FAQ.
https://c-faq.com/null/machexamp.html It's just a bit of fun trivia that
doesn't really matter unless you have a time machine.  Even if you invented
a time machine, the code here would still be fine because we have a NULL
test before dereferencing the results of our pointer math.

regards,
dan carpenter
Thread (23 messages) 23 messages, 6 authors, last reply 2026-07-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help