From: Alejandro Colomar Date: Mon, 29 Jan 2024 12:50:33 +0000 (+0100) Subject: lib/, src/: Use STRFTIME() instead of its pattern X-Git-Tag: 4.15.1~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0460dac019c5b28471aed1f184ce470797dd26a6;p=thirdparty%2Fshadow.git lib/, src/: Use STRFTIME() instead of its pattern Reviewed-by: "Serge E. Hallyn" Signed-off-by: Alejandro Colomar --- diff --git a/lib/failure.c b/lib/failure.c index 376b102b4..e42e71073 100644 --- a/lib/failure.c +++ b/lib/failure.c @@ -14,11 +14,13 @@ #include #include #include + #include "defines.h" #include "faillog.h" #include "failure.h" #include "memzero.h" #include "prototypes.h" +#include "string/strftime.h" #include "string/strtcpy.h" @@ -252,7 +254,7 @@ void failprint (const struct faillog *fail) /* * Print all information we have. */ - (void) strftime (lasttimeb, sizeof lasttimeb, "%c", tp); + STRFTIME(lasttimeb, "%c", tp); /*@-formatconst@*/ (void) printf (ngettext ("%d failure since last login.\n" diff --git a/src/chage.c b/src/chage.c index ca61cffdc..1c4a20172 100644 --- a/src/chage.c +++ b/src/chage.c @@ -34,6 +34,7 @@ #include "shadowio.h" #include "shadowlog.h" #include "string/sprintf.h" +#include "string/strftime.h" #include "string/strtcpy.h" #include "time/day_to_str.h" /*@-exitarg@*/ @@ -253,7 +254,7 @@ print_day_as_date(long day) return; } - (void) strftime (buf, sizeof buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm); + STRFTIME(buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm); (void) puts (buf); } diff --git a/src/faillog.c b/src/faillog.c index 3681e5955..611802731 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -18,6 +18,7 @@ #include #include #include + #include "defines.h" #include "faillog.h" #include "memzero.h" @@ -25,6 +26,8 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "shadowlog.h" +#include "string/strftime.h" + /* local function prototypes */ NORETURN static void usage (int status); @@ -167,7 +170,7 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force) fprintf (stderr, "Cannot read time from faillog.\n"); return; } - strftime (ptime, sizeof (ptime), "%D %H:%M:%S %z", tm); + STRFTIME(ptime, "%D %H:%M:%S %z", tm); cp = ptime; printf ("%-9s %5d %5d ", diff --git a/src/lastlog.c b/src/lastlog.c index 5500fbc5f..74b2faea3 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -22,6 +22,7 @@ #ifdef HAVE_LL_HOST #include #endif + #include "defines.h" #include "prototypes.h" #include "getdef.h" @@ -29,6 +30,8 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "shadowlog.h" +#include "string/strftime.h" + /* * Needed for MkLinux DR1/2/2.1 - J. @@ -156,7 +159,7 @@ static void print_one (/*@null@*/const struct passwd *pw) if (tm == NULL) { cp = "(unknown)"; } else { - strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm); + STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y", tm); cp = ptime; } if (ll.ll_time == (time_t) 0) { diff --git a/src/login.c b/src/login.c index 04423a21d..16236de32 100644 --- a/src/login.c +++ b/src/login.c @@ -38,8 +38,10 @@ #include "exitcodes.h" #include "shadowlog.h" #include "string/sprintf.h" +#include "string/strftime.h" #include "string/strtcpy.h" + #ifdef USE_PAM #include "pam_defs.h" @@ -1249,12 +1251,12 @@ int main (int argc, char **argv) #ifdef ENABLE_LASTLOG if ( getdef_bool ("LASTLOG_ENAB") && pwd->pw_uid <= (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL) - && (ll.ll_time != 0)) { + && (ll.ll_time != 0)) + { time_t ll_time = ll.ll_time; - (void) strftime (ptime, sizeof (ptime), - "%a %b %e %H:%M:%S %z %Y", - localtime (&ll_time)); + STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y", + localtime(&ll_time)); printf (_("Last login: %s on %s"), ptime, ll.ll_line); #ifdef HAVE_LL_HOST /* __linux__ || SUN4 */