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/journal/journald-syslog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/journal/journald-syslog.c') diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index cbb944f287..fee7d91572 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -46,7 +46,7 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned .msg_iovlen = n_iovec, .msg_name = &sa, .msg_namelen = offsetof(union sockaddr_union, un.sun_path) - + sizeof("/run/systemd/journal/syslog") - 1, + + strlen("/run/systemd/journal/syslog"), }; struct cmsghdr *cmsg; union { -- cgit v1.2.3-54-g00ecf