From f8294e4175918117ca6c131720bcf287eadcd029 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 15 Mar 2014 11:40:07 -0700 Subject: 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. --- src/libsystemd/sd-bus/bus-socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsystemd/sd-bus/bus-socket.c') diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index 0c4b6af447..016f8a1c9f 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -227,8 +227,8 @@ static int bus_socket_auth_verify_client(sd_bus *b) { if (f) b->can_fds = - (f - e == sizeof("\r\nAGREE_UNIX_FD") - 1) && - memcmp(e + 2, "AGREE_UNIX_FD", sizeof("AGREE_UNIX_FD") - 1) == 0; + (f - e == strlen("\r\nAGREE_UNIX_FD")) && + memcmp(e + 2, "AGREE_UNIX_FD", strlen("AGREE_UNIX_FD")) == 0; b->rbuffer_size -= (start - (char*) b->rbuffer); memmove(b->rbuffer, start, b->rbuffer_size); -- cgit v1.2.3-54-g00ecf