From: Sami Kerola Date: Sat, 9 Aug 2014 07:38:58 +0000 (+0100) Subject: logger: optimize string initializations X-Git-Tag: v2.26-rc1~498^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c3bd5bf63093dfe54206be867c3d0c1fe46510;p=thirdparty%2Futil-linux.git logger: optimize string initializations Setting whole array to be completely full of nulls cannot be as quick as making the only significant member of the array when needed. Signed-off-by: Sami Kerola --- diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 8ae00b26a5..884a1197b0 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -299,11 +299,12 @@ static pid_t get_process_id(struct logger_ctl *ctl) static void syslog_rfc3164(struct logger_ctl *ctl, char *msg) { - char *buf, pid[30] = { '\0' }, *cp, *tp, *hostname, *dot; + char *buf, pid[30], *cp, *tp, *hostname, *dot; time_t now; pid_t process; int len; + *pid = '\0'; if (ctl->fd < 0) return; if ((process = get_process_id(ctl))) @@ -334,13 +335,14 @@ static void syslog_rfc3164(struct logger_ctl *ctl, char *msg) static void syslog_rfc5424(struct logger_ctl *ctl, char *msg) { char *buf, *tag = NULL, *hostname = NULL; - char pid[32] = { '\0' }, time[64] = { '\0' }, timeq[80] = { '\0' }; + char pid[32], time[64], timeq[80]; struct ntptimeval ntptv; struct timeval tv; struct tm *tm; pid_t process; int len; + *pid = *time = *timeq = '\0'; if (ctl->fd < 0) return;