Skip to content

Commit d34a88f

Browse files
committed
Use NULL instead of 0
GCC 15 introduced a new warning "-Wzero-as-null-pointer-constant" which checks for places where '0' has been used in place of the NULL macro. This showed a few places in Unit where we were using '0' instead of the more correct NULL. 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>
1 parent 7e1f4a7 commit d34a88f

7 files changed

+19
-19
lines changed

src/nxt_buf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ struct nxt_buf_s {
189189

190190
#define nxt_buf_mem_set_size(bm, size) \
191191
do { \
192-
(bm)->start = 0; \
192+
(bm)->start = NULL; \
193193
(bm)->end = (void *) size; \
194194
} while (0)
195195

src/nxt_unit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ nxt_unit_ctx_init(nxt_unit_impl_t *lib, nxt_unit_ctx_impl_t *ctx_impl,
716716
ctx_impl->req.req.unit = &lib->unit;
717717

718718
ctx_impl->read_port = NULL;
719-
ctx_impl->requests.slot = 0;
719+
ctx_impl->requests.slot = NULL;
720720

721721
return NXT_UNIT_OK;
722722
}

src/python/nxt_python_asgi_http.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ static PyObject *nxt_py_asgi_http_done(PyObject *self, PyObject *future);
4545

4646

4747
static PyMethodDef nxt_py_asgi_http_methods[] = {
48-
{ "receive", nxt_py_asgi_http_receive, METH_NOARGS, 0 },
49-
{ "send", nxt_py_asgi_http_send, METH_O, 0 },
50-
{ "_done", nxt_py_asgi_http_done, METH_O, 0 },
51-
{ NULL, NULL, 0, 0 }
48+
{ "receive", nxt_py_asgi_http_receive, METH_NOARGS, NULL },
49+
{ "send", nxt_py_asgi_http_send, METH_O, NULL },
50+
{ "_done", nxt_py_asgi_http_done, METH_O, NULL },
51+
{}
5252
};
5353

5454
static PyAsyncMethods nxt_py_asgi_async_methods = {

src/python/nxt_python_asgi_lifespan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ static void nxt_py_asgi_lifespan_dealloc(PyObject *self);
4848

4949

5050
static PyMethodDef nxt_py_asgi_lifespan_methods[] = {
51-
{ "receive", nxt_py_asgi_lifespan_receive, METH_NOARGS, 0 },
52-
{ "send", nxt_py_asgi_lifespan_send, METH_O, 0 },
53-
{ "_done", nxt_py_asgi_lifespan_done, METH_O, 0 },
54-
{ NULL, NULL, 0, 0 }
51+
{ "receive", nxt_py_asgi_lifespan_receive, METH_NOARGS, NULL },
52+
{ "send", nxt_py_asgi_lifespan_send, METH_O, NULL },
53+
{ "_done", nxt_py_asgi_lifespan_done, METH_O, NULL },
54+
{}
5555
};
5656

5757
static PyMemberDef nxt_py_asgi_lifespan_members[] = {

src/python/nxt_python_asgi_websocket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ static PyObject *nxt_py_asgi_websocket_done(PyObject *self, PyObject *future);
7070

7171

7272
static PyMethodDef nxt_py_asgi_websocket_methods[] = {
73-
{ "receive", nxt_py_asgi_websocket_receive, METH_NOARGS, 0 },
74-
{ "send", nxt_py_asgi_websocket_send, METH_O, 0 },
75-
{ "_done", nxt_py_asgi_websocket_done, METH_O, 0 },
76-
{ NULL, NULL, 0, 0 }
73+
{ "receive", nxt_py_asgi_websocket_receive, METH_NOARGS, NULL },
74+
{ "send", nxt_py_asgi_websocket_send, METH_O, NULL },
75+
{ "_done", nxt_py_asgi_websocket_done, METH_O, NULL },
76+
{}
7777
};
7878

7979
static PyAsyncMethods nxt_py_asgi_async_methods = {

src/python/nxt_python_wsgi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ static PyMethodDef nxt_py_write_method[] = {
108108

109109

110110
static PyMethodDef nxt_py_input_methods[] = {
111-
{ "read", (PyCFunction) nxt_py_input_read, METH_VARARGS, 0 },
112-
{ "readline", (PyCFunction) nxt_py_input_readline, METH_VARARGS, 0 },
113-
{ "readlines", (PyCFunction) nxt_py_input_readlines, METH_VARARGS, 0 },
114-
{ NULL, NULL, 0, 0 }
111+
{ "read", (PyCFunction) nxt_py_input_read, METH_VARARGS, NULL },
112+
{ "readline", (PyCFunction) nxt_py_input_readline, METH_VARARGS, NULL },
113+
{ "readlines", (PyCFunction) nxt_py_input_readlines, METH_VARARGS, NULL },
114+
{}
115115
};
116116

117117

src/ruby/nxt_ruby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ nxt_ruby_rack_result_body(nxt_unit_request_info_t *req, VALUE result)
10811081
}
10821082

10831083
} else if (rb_respond_to(body, rb_intern("each"))) {
1084-
rb_block_call(body, rb_intern("each"), 0, 0,
1084+
rb_block_call(body, rb_intern("each"), 0, NULL,
10851085
nxt_ruby_rack_result_body_each, (VALUE) (uintptr_t) req);
10861086

10871087
} else {

0 commit comments

Comments
 (0)