]> git.ipfire.org Git - thirdparty/systemd.git/commit
tree-wide: do not use (void) asprintf
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Jul 2021 09:37:21 +0000 (11:37 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Jul 2021 09:11:25 +0000 (11:11 +0200)
commit12619d0a80f4ecc445cf7f880b2359d82bcd1bc6
treeac4de92ca609a38b8ff784e59a74fa878c78f950
parentcb3e854fedbeb13a5502487f2357d3bde9057a53
tree-wide: do not use (void) asprintf

asprintf(3) says that the pointer is "undefined" after a failed call.
In the current glibc implementation it is just NULL. In principle the
call could return a valid pointer with bad contents or something.

We have two styles of error handling: in a majority of cases we would
check the return value, but sometimes we used (void) and relied on the
pointer not being set. In practice both styles should be equivalent,
but gcc doesn't like the second one with -Wunused-result. (Though only
sometimes. E.g. on my F34 box I don't get the same warnings as in CI,
even though the compiler version is very similar and the compilation
options are the same…). It's also nice to be consistent in our code base.
So let's always use the first style of error checking.
src/analyze/analyze-security.c
src/basic/rlimit-util.c
src/libsystemd/sd-bus/bus-error.c
src/shared/varlink.c