]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/sysctl/sysctl.c
Use strlen even for constant strings
authorJosh Triplett <josh@joshtriplett.org>
Sat, 15 Mar 2014 18:40:07 +0000 (11:40 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Mar 2014 13:52:56 +0000 (09:52 -0400)
commitf8294e4175918117ca6c131720bcf287eadcd029
treec5b2f4d3088fbd4fd75989b3f7eed128681951e1
parent039dd4afd64a8c8413ff28d43f533c30c5a06a16
Use strlen even for constant strings

GCC optimizes strlen("string constant") to a constant, even with -O0.
Thus, replace patterns like sizeof("string constant")-1 with
strlen("string constant") where possible, for clarity.  In particular,
for expressions intended to add up the lengths of components going into
a string, this often makes it clearer that the expression counts the
trailing '\0' exactly once, by putting the +1 for the '\0' at the end of
the expression, rather than hidden in a sizeof in the middle of the
expression.
13 files changed:
src/core/dbus.c
src/core/service.c
src/journal/journald-server.c
src/journal/journald-syslog.c
src/libsystemd/sd-bus/bus-kernel.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-bus/bus-track.c
src/shared/cgroup-util.c
src/shared/unit-name.c
src/shared/util.c
src/sysctl/sysctl.c
src/systemctl/systemctl.c
src/udev/udev-rules.c