Skip to content

Conversation

daddesio
Copy link

@daddesio daddesio commented Jul 6, 2022

Compiling under Clang 13 with -Wextra resulted in the following warning:

src/http.c:3470:31: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
    request=va_arg(_ap,char *)-(char *)NULL;

It seems subtracting a null pointer is undefined behavior, which we can avoid by casting to intptr_t instead.

Request macros (e.g. OP_GET_SERVER_INFO) already do a simple cast ((char*)_request) rather than addition with null pointer (_request+(char*)NULL) so nothing needs to be changed on that end.

Subtracting a null pointer is undefined behavior according to
Clang 13 (-Wnull-pointer-subtraction). Avoid this by casting to
intptr_t instead.

Request macros (e.g. OP_GET_SERVER_INFO) already do a simple cast
`((char*)_request)` rather than addition with null pointer
`(_request+(char*)NULL)` so nothing needs to be changed on that end.
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