When if clause that continues throughout whole function it usually can be shorten to immediate action, e.g., in this case return on the spot not at end of the function. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- misc-utils/logger.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 65e468c..5506022 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -273,24 +273,22 @@ static void mysyslog(int fd, int logflags, int pri, char *tag, char *msg) char buf[1000], pid[30], *cp, *tp; time_t now; - if (fd > -1) { - if (logflags & LOG_PID) - snprintf(pid, sizeof(pid), "[%d]", getpid()); - else - pid[0] = 0; - if (tag) - cp = tag; - else - cp = xgetlogin(); - time(&now); - tp = ctime(&now) + 4; - - snprintf(buf, sizeof(buf), "<%d>%.15s %.200s%s: %.400s", - pri, tp, cp, pid, msg); - - if (write_all(fd, buf, strlen(buf) + 1) < 0) - warn(_("write failed")); - } + if (fd < 0) + return; + if (logflags & LOG_PID) + snprintf(pid, sizeof(pid), "[%d]", getpid()); + else + pid[0] = 0; + if (tag) + cp = tag; + else + cp = xgetlogin(); + time(&now); + tp = ctime(&now) + 4; + snprintf(buf, sizeof(buf), "<%d>%.15s %.200s%s: %.400s", + pri, tp, cp, pid, msg); + if (write_all(fd, buf, strlen(buf) + 1) < 0) + warn(_("write failed")); } static void __attribute__ ((__noreturn__)) usage(FILE *out) -- 2.0.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html