[systemd-devel] [bug] (char*)NULL should be used in variadic functions

Lennart Poettering lennart at poettering.net
Mon Feb 4 02:15:15 PST 2013


On Wed, 30.01.13 11:07, Vasily Kulikov (segoon at openwall.com) wrote:

> Hi,
> 
> systemd uses plain NULL as an argument of variadic functions, which is a
> UB in C.  (char*)NULL should be used instead.  Plain NULL may be defined
> as "0" or smth.
> 
> >From C99:
> 
> "6.3.2.3 Pointers
> 
> ...
> 
> 3
> An integer constant expression with the value 0, or such an expression
> cast to type void *, is called a null pointer constant.
> 
> ...
> 
> 7.17 Common definitions <stddef.h>
> 
> ...
> 
> 3
> The macros are NULL which expands to an implementation-defined null
> pointer constant;"
> 
> NULL is wrongly used e.g. in sd_journal_send() in
> src/journal/test-journal-send.c.

We actually care about readability of the sources and non-Linux systems
are out-of-focus for us. Can you tell me which Linux system has
sizeof(void*) != sizeof(char*)? Otherwise, I only see this as pointless
excercise of making our sources less readable...

Or am I missing something here?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list