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.
FILE *fp;
struct tm *tm;
time_t t1;
FILE *fp;
struct tm *tm;
time_t t1;
- char *color, str[MAXLINE] = "";
ll = PARA_MIN(ll, NUM_LOGLEVELS - 1);
ll = PARA_MAX(ll, LL_DEBUG);
ll = PARA_MIN(ll, NUM_LOGLEVELS - 1);
ll = PARA_MAX(ll, LL_DEBUG);
color = daemon_test_flag(DF_COLOR_LOG)? me->log_colors[ll] : NULL;
if (color)
fprintf(fp, "%s", color);
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);
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)) {
fprintf(fp, "%s ", str);
}
if (daemon_test_flag(DF_LOG_HOSTNAME)) {