lib/, src/: Use STRFTIME() instead of its pattern

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-29 13:50:33 +01:00
parent b3affb29cf
commit 0460dac019
5 changed files with 19 additions and 8 deletions
+3 -1
View File
@@ -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"
+2 -1
View File
@@ -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);
}
+4 -1
View File
@@ -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 ",
+4 -1
View File
@@ -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) {
+6 -4
View File
@@ -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 */