summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola2014-08-09 09:38:58 +0200
committerSami Kerola2014-08-15 22:52:12 +0200
commit77c3bd5bf63093dfe54206be867c3d0c1fe46510 (patch)
tree4c0308103a917e753b1b8e079bfe7bc2252b2310
parentlogger: remove openlog(3) options (diff)
downloadkernel-qcow2-util-linux-77c3bd5bf63093dfe54206be867c3d0c1fe46510.tar.gz
kernel-qcow2-util-linux-77c3bd5bf63093dfe54206be867c3d0c1fe46510.tar.xz
kernel-qcow2-util-linux-77c3bd5bf63093dfe54206be867c3d0c1fe46510.zip
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 <kerolasa@iki.fi>
-rw-r--r--misc-utils/logger.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 8ae00b26a..884a1197b 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;