summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-bus/bus-track.c
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2014-03-15 19:40:07 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-16 14:52:56 +0100
commitf8294e4175918117ca6c131720bcf287eadcd029 (patch)
treec5b2f4d3088fbd4fd75989b3f7eed128681951e1 /src/libsystemd/sd-bus/bus-track.c
parentnspawn: UP the host side of the veth pair after adding it to a bridge (diff)
downloadsystemd-f8294e4175918117ca6c131720bcf287eadcd029.tar.xz
systemd-f8294e4175918117ca6c131720bcf287eadcd029.zip
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.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-track.c')
-rw-r--r--src/libsystemd/sd-bus/bus-track.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
index fd368e4368..e21959d01d 100644
--- a/src/libsystemd/sd-bus/bus-track.c
+++ b/src/libsystemd/sd-bus/bus-track.c
@@ -51,7 +51,7 @@ struct sd_bus_track {
({ \
char *_x; \
size_t _l = strlen(name); \
- _x = alloca(sizeof(MATCH_PREFIX)-1+_l+sizeof(MATCH_SUFFIX)); \
+ _x = alloca(strlen(MATCH_PREFIX)+_l+strlen(MATCH_SUFFIX)+1); \
strcpy(stpcpy(stpcpy(_x, MATCH_PREFIX), name), MATCH_SUFFIX); \
_x; \
})