From 0327689de0c98e5b372c18b259f9956ac1de2fc3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 26 Sep 2002 08:39:20 +0000 Subject: [PATCH] (get_ids): Use strtoul, not strtol. Remove some casts. --- src/install.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/install.c b/src/install.c index 5f81fdb..c27c3b7 100644 --- a/src/install.c +++ b/src/install.c @@ -554,11 +554,11 @@ get_ids (void) pw = getpwnam (owner_name); if (pw == NULL) { - long int tmp_long; - if (xstrtol (owner_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK - || !(0 <= tmp_long && (uid_t) tmp_long <= UID_T_MAX)) + unsigned long int tmp; + if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK + || UID_T_MAX < tmp) error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name)); - owner_id = (uid_t) tmp_long; + owner_id = tmp; } else owner_id = pw->pw_uid; @@ -572,11 +572,11 @@ get_ids (void) gr = getgrnam (group_name); if (gr == NULL) { - long int tmp_long; - if (xstrtol (group_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK - || !(0 <= tmp_long && (gid_t) tmp_long <= GID_T_MAX)) + unsigned long int tmp; + if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK + || GID_T_MAX < tmp) error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name)); - group_id = (gid_t) tmp_long; + group_id = tmp; } else group_id = gr->gr_gid; -- 2.7.4