diff options
author | Alejandro Colomar <alx@kernel.org> | 2024-01-29 13:50:33 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2024-03-24 00:16:00 +0100 |
commit | 0460dac019c5b28471aed1f184ce470797dd26a6 (patch) | |
tree | 1339366959eb7da36c53281dcaa298278bddc7f3 | |
parent | b3affb29cff0b16e24a53e0b629daffb597c499c (diff) |
lib/, src/: Use STRFTIME() instead of its pattern
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | lib/failure.c | 4 | ||||
-rw-r--r-- | src/chage.c | 3 | ||||
-rw-r--r-- | src/faillog.c | 5 | ||||
-rw-r--r-- | src/lastlog.c | 5 | ||||
-rw-r--r-- | src/login.c | 10 |
5 files changed, 19 insertions, 8 deletions
diff --git a/lib/failure.c b/lib/failure.c index 376b102b..e42e7107 100644 --- a/lib/failure.c +++ b/lib/failure.c @@ -14,11 +14,13 @@ #include <fcntl.h> #include <stdio.h> #include <unistd.h> + #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 ca61cffd..1c4a2017 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 3681e595..61180273 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -18,6 +18,7 @@ #include <sys/types.h> #include <time.h> #include <assert.h> + #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 5500fbc5..74b2faea 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -22,6 +22,7 @@ #ifdef HAVE_LL_HOST #include <net/if.h> #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 04423a21..16236de3 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 */ |