HomeClusterLabs Projects

Build: 2 *.c: restore GCC 9 -Werror buildability: avoid NULL to '%s' arg

Description

Build: 2 *.c: restore GCC 9 -Werror buildability: avoid NULL to '%s' arg

Sadly, pacemaker codebase seems to be possibly heavily spoiled with
this undefined behaviour when possibly passing NULL corresponding to
'%s' format specifier argument, so for the time being, fix just what
new GCC 9 started to spot[*] (due to build-time constant NULLs, which
is an immediate proof) since these occurrences boil down to mere
thinkos. Related to that, would be wise to start rolling out
nonnull annotations to preserve more general sanity in this self
explanatory aspect.

Looking at libqb code (end destination of "crm_log" processing), there's
nothing to implicitly mask NULL with a predestined string explicitly
(like glibc make do with "(null)" in majority of the cases), so unless
merely a blackbox is used for logging (qb_vsnprintf_serialize seems to
deal with such a NULL gracefully), passing NULLs where a character array
is expected is rather dangerous without the prior knowledge of
particular libc (vsnprintf) implementation.

Details

Event Timeline