Use function format attribute where applicable

Allow the compiler to verify the format string against the supplied
arguments.

    chage.c:239:51: warning: format not a string literal, format string not checked [-Wformat-nonliteral]
      239 |                 (void) strftime (buf, sizeof buf, format, tp);
          |                                                   ^~~~~~
This commit is contained in:
Christian Göttsche
2022-08-05 17:40:42 +02:00
committed by Serge Hallyn
parent 477c8e6f42
commit c6c8130db4
5 changed files with 7 additions and 11 deletions

View File

@@ -223,20 +223,12 @@ static void print_date (time_t date)
{
struct tm *tp;
char buf[80];
char format[80];
if (iflg) {
(void) snprintf (format, 80, "%%Y-%%m-%%d");
}
else {
(void) snprintf (format, 80, "%%b %%d, %%Y");
}
tp = gmtime (&date);
if (NULL == tp) {
(void) printf ("time_t: %lu\n", (unsigned long)date);
} else {
(void) strftime (buf, sizeof buf, format, tp);
(void) strftime (buf, sizeof buf, iflg ? "%%Y-%%m-%%d" : "%%b %%d, %%Y", tp);
(void) puts (buf);
}
}