From: Andre Noll Date: Thu, 22 Oct 2009 20:47:19 +0000 (+0200) Subject: daemon: Avoid using MAXLINE. X-Git-Tag: v0.4.0~7^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b3490104baea629c0d5c472abc63f24b4fe01000;ds=sidebyside daemon: Avoid using MAXLINE. MAXLINE is kind of depricated. Just use a 100 byte buffer and make the scope of the buffer more local. Also, kill the pointless initialization to an empty string. --- diff --git a/daemon.c b/daemon.c index ae183d8e..011ece6d 100644 --- a/daemon.c +++ b/daemon.c @@ -331,7 +331,7 @@ __printf_2_3 void para_log(int ll, const char* fmt,...) FILE *fp; struct tm *tm; time_t t1; - char *color, str[MAXLINE] = ""; + char *color; ll = PARA_MIN(ll, NUM_LOGLEVELS - 1); ll = PARA_MAX(ll, LL_DEBUG); @@ -342,11 +342,11 @@ __printf_2_3 void para_log(int ll, const char* fmt,...) color = daemon_test_flag(DF_COLOR_LOG)? me->log_colors[ll] : NULL; if (color) fprintf(fp, "%s", color); - if (daemon_test_flag(DF_LOG_TIME)) { - /* date and time */ + if (daemon_test_flag(DF_LOG_TIME)) { /* print date and time */ + char str[100]; time(&t1); tm = localtime(&t1); - strftime(str, MAXLINE, "%b %d %H:%M:%S", tm); + strftime(str, sizeof(str), "%b %d %H:%M:%S", tm); fprintf(fp, "%s ", str); } if (daemon_test_flag(DF_LOG_HOSTNAME)) {