Skip to content

Use NULL instead of 0 as null pointer constant #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ac000
Copy link
Member

@ac000 ac000 commented May 21, 2025

Use NULL instead of 0 as null pointer constant

GCC 15 enabled "-Wzero-as-null-pointer-constant" for C, which checks for
places where '0' has been used as a null pointer constant.

This showed a few places in Unit where we were using '0' instead of the
more correct NULL macro. E.g.

  $ make -j4 EXTRA_CFLAGS=-Wzero-as-null-pointer-constant
  ...
  src/nxt_buf.c: In function ‘nxt_buf_mmap_alloc’:
  src/nxt_buf.h:192:21: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
    192 |         (bm)->start = 0;                                                      \
        |                     ^
  src/nxt_buf.c:135:9: note: in expansion of macro ‘nxt_buf_mem_set_size’
    135 |         nxt_buf_mem_set_size(&b->mem, size);
        |         ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

ac000 added 2 commits May 22, 2025 01:04
GCC 15 enabled "-Wzero-as-null-pointer-constant" for C, which checks for
places where '0' has been used as a null pointer constant.

This showed a few places in Unit where we were using '0' instead of the
more correct NULL macro. E.g.

  $ make -j4 EXTRA_CFLAGS=-Wzero-as-null-pointer-constant
  ...
  src/nxt_buf.c: In function ‘nxt_buf_mmap_alloc’:
  src/nxt_buf.h:192:21: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
    192 |         (bm)->start = 0;                                                      \
        |                     ^
  src/nxt_buf.c:135:9: note: in expansion of macro ‘nxt_buf_mem_set_size’
    135 |         nxt_buf_mem_set_size(&b->mem, size);
        |         ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Seems OpenJDK 17 is no longer available in Debian testing.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
@ac000 ac000 changed the title Use NULL instead of 0 Use NULL instead of 0 as null pointer constant May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant