src/passwd.c: Simplify, by calling a2sl() instead of str2sl()

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-09 21:21:00 +01:00
parent b178fed180
commit e341291f99
+15 -10
View File
@@ -21,7 +21,7 @@
#include <time.h>
#include "agetpass.h"
#include "atoi/str2i.h"
#include "atoi/a2i.h"
#include "defines.h"
#include "getdef.h"
#include "memzero.h"
@@ -722,7 +722,8 @@ static void update_shadow (void)
* appropriate internal format. For finer resolute the chage
* command must be used.
*/
int main (int argc, char **argv)
int
main(int argc, char **argv)
{
const struct passwd *pw; /* Password file entry for user */
@@ -800,8 +801,9 @@ int main (int argc, char **argv)
usage (E_SUCCESS);
/*@notreached@*/break;
case 'i':
if ( (str2sl(&inact, optarg) == -1)
|| (inact < -1)) {
if (a2sl(&inact, optarg, NULL, 0, -1, LONG_MAX)
== -1)
{
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
@@ -819,8 +821,9 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'n':
if ( (str2sl(&age_min, optarg) == -1)
|| (age_min < -1)) {
if (a2sl(&age_min, optarg, NULL, 0, -1, LONG_MAX)
== -1)
{
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
@@ -854,8 +857,9 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'w':
if ( (str2sl(&warn, optarg) == -1)
|| (warn < -1)) {
if (a2sl(&warn, optarg, NULL, 0, -1, LONG_MAX)
== -1)
{
(void) fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
@@ -865,8 +869,9 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'x':
if ( (str2sl(&age_max, optarg) == -1)
|| (age_max < -1)) {
if (a2sl(&age_max, optarg, NULL, 0, -1, LONG_MAX)
== -1)
{
(void) fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);