]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-bus: rework assert to make the gcc happy 32135/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 7 Apr 2024 09:13:06 +0000 (11:13 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 7 Apr 2024 09:15:19 +0000 (11:15 +0200)
commit41733186c4a946dd92fcfe754ce0f8f3c0737538
treef349ea56e302f1970d9ed55745d79c0f4ca32e21
parent6a4607a3c8c6dcd31bed306af04b63f6f2bd2a1b
sd-bus: rework assert to make the gcc happy

With gcc-14.0.1-0.13.fc40, when compiling with -O2, the compiler doesn't understand
that sd_bus_error_setf() always returns negative on error when <name> is provided:

[28/576] Compiling C object systemd-resolved.p/src_resolve_resolved-bus.c.o
../src/resolve/resolved-bus.c: In function ‘call_link_method’:
../src/resolve/resolved-bus.c:1763:16: warning: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
 1763 |         return handler(message, l, error);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
../src/resolve/resolved-bus.c:1749:15: note: ‘l’ was declared here
 1749 |         Link *l;
      |               ^
../src/resolve/resolved-bus.c: In function ‘bus_method_get_link’:
../src/resolve/resolved-bus.c:1822:13: warning: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
 1822 |         p = link_bus_path(l);
      |             ^~~~~~~~~~~~~~~~
../src/resolve/resolved-bus.c:1810:15: note: ‘l’ was declared here
 1810 |         Link *l;
      |               ^
...

Let's make the assertion a bit more explicit. With this, the warning goes away,
but I think it's more obvious to a human reader too.
src/libsystemd/sd-bus/bus-error.c