From f011db58ce49a5912b6105171b528e3bd06e02c2 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 6 Jan 2017 12:56:22 -0500 Subject: [PATCH] mark strftime calls using struct tm in time module as safe disable -Wformat-nonliteral temporarily --- src/modules/time/time.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/time/time.c b/src/modules/time/time.c index b3f93d628..4f2d2a177 100644 --- a/src/modules/time/time.c +++ b/src/modules/time/time.c @@ -119,7 +119,10 @@ time_datestring_format(Instance *inst, char *buf, int bufsz) strftime(buf, bufsz, "%F", (const struct tm *)tm); break; case CLOCK_DATE_DISPLAY_CUSTOM: +/* disable warning for known-safe code */ +DISABLE_WARNING(format-nonliteral, format-nonliteral, format-nonliteral) if (!strftime(buf, bufsz, inst->cfg->time_str[1] ?: default_str, (const struct tm *)tm)) +ENABLE_WARNING(format-nonliteral, format-nonliteral, format-nonliteral) strncpy(buf, "ERROR", bufsz - 1); break; default: break; @@ -141,7 +144,10 @@ time_string_format(Instance *inst, char *buf, int bufsz) tt = (time_t)(timev.tv_sec); tm = localtime(&tt); TZUNSET(); +/* disable warning for known-safe code */ +DISABLE_WARNING(format-nonliteral, format-nonliteral, format-nonliteral) if (!strftime(buf, bufsz, inst->cfg->time_str[0] ?: default_fmt, (const struct tm *)tm)) +ENABLE_WARNING(format-nonliteral, format-nonliteral, format-nonliteral) strncpy(buf, "ERROR", bufsz - 1); return tm->tm_sec; }