Explicit Pointer Comparisons with 'NULL' #1036
ashtonjamesd
started this conversation in
General
Replies: 1 comment
-
|
On Tue, 16 Dec 2025 03:07:45 -0800 ashtonㅤ ***@***.***> wrote:
### What would you like to discuss?
Should `!= NULL` and `== NULL` **always** be preferred when comparing pointers? This is instead of `(ptr)` and `(!ptr)`. I am asking as there are instances of both throughout the nginx codebase and whether it is worth amending.
Personally I prefer the (ptr)/(!ptr) form where it's treated like a
boolean, but doing the explicit check seems to be the more common way
in nginx.
As a general rule, if in doubt about coding style, do it like the
surrounding code.
Probably not worth the code churn to change for the sake of change.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Should
!= NULLand== NULLalways be preferred when comparing pointers? This is instead of(ptr)and(!ptr). I am asking as there are instances of both throughout the nginx codebase and whether it is worth amending.Beta Was this translation helpful? Give feedback.
All reactions