diff options
author | Alejandro Colomar <alx@kernel.org> | 2024-01-29 15:19:44 +0100 |
---|---|---|
committer | Serge Hallyn <serge@hallyn.com> | 2024-03-14 16:30:46 -0500 |
commit | 82e28ad534dab41697a384c2e7cf563e8a2a0eb1 (patch) | |
tree | 659978a80f9be1d7b9c471b4fc7ba2410798fc8a | |
parent | 19edb06fd2e4efe7f431b57ff9e7f05265e6fb16 (diff) |
src/: Use DAY_TO_STR() instead of its pattern
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | src/chage.c | 18 | ||||
-rw-r--r-- | src/passwd.c | 2 | ||||
-rw-r--r-- | src/usermod.c | 5 |
3 files changed, 12 insertions, 13 deletions
diff --git a/src/chage.c b/src/chage.c index 5788a190..88e06cd3 100644 --- a/src/chage.c +++ b/src/chage.c @@ -181,11 +181,10 @@ static int new_fields (void) return 0; } - if (-1 == lstchgdate || lstchgdate > LONG_MAX / DAY) { - strcpy (buf, "-1"); - } else { - date_to_str (sizeof(buf), buf, lstchgdate * DAY); - } + if (-1 == lstchgdate || lstchgdate > LONG_MAX / DAY) + strcpy(buf, "-1"); + else + DAY_TO_STR(buf, lstchgdate); change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)")); @@ -212,11 +211,10 @@ static int new_fields (void) return 0; } - if (-1 == expdate || LONG_MAX / DAY < expdate) { - strcpy (buf, "-1"); - } else { - date_to_str (sizeof(buf), buf, expdate * DAY); - } + if (-1 == expdate || LONG_MAX / DAY < expdate) + strcpy(buf, "-1"); + else + DAY_TO_STR(buf, expdate); change_field (buf, sizeof buf, _("Account Expiration Date (YYYY-MM-DD)")); diff --git a/src/passwd.c b/src/passwd.c index 1b797892..ed92bc7c 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -453,7 +453,7 @@ static void print_status (const struct passwd *pw) sp = prefix_getspnam (pw->pw_name); /* local, no need for xprefix_getspnam */ if (NULL != sp) { - date_to_str (sizeof(date), date, sp->sp_lstchg * DAY), + DAY_TO_STR(date, sp->sp_lstchg), (void) printf ("%s %s %s %ld %ld %ld %ld\n", pw->pw_name, pw_status (sp->sp_pwdp), diff --git a/src/usermod.c b/src/usermod.c index 63fb996d..dff0487a 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -586,8 +586,9 @@ static void new_spent (struct spwd *spent) if (eflg) { /* log dates rather than numbers of days. */ char new_exp[16], old_exp[16]; - date_to_str (sizeof(new_exp), new_exp, user_newexpire * DAY); - date_to_str (sizeof(old_exp), old_exp, user_expire * DAY); + + DAY_TO_STR(new_exp, user_newexpire); + DAY_TO_STR(old_exp, user_expire); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing expiration date", |