lib/, src/: get_gid(): Use the usual -1 as an error code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-05 16:54:55 -06:00
committed by Serge Hallyn
parent ea253cb275
commit 470baeabbd
6 changed files with 11 additions and 8 deletions
+6 -3
View File
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
#ident "$Id$"
@@ -11,7 +12,9 @@
#include "prototypes.h"
#include "defines.h"
int get_gid (const char *gidstr, gid_t *gid)
int
get_gid(const char *gidstr, gid_t *gid)
{
long long val;
char *endptr;
@@ -22,10 +25,10 @@ int get_gid (const char *gidstr, gid_t *gid)
|| ('\0' != *endptr)
|| (0 != errno)
|| (/*@+longintegral@*/val != (gid_t)val)/*@=longintegral@*/) {
return 0;
return -1;
}
*gid = val;
return 1;
return 0;
}
+1 -1
View File
@@ -105,7 +105,7 @@ struct group *sgetgrent (const char *buf)
}
grent.gr_name = grpfields[0];
grent.gr_passwd = grpfields[1];
if (get_gid (grpfields[2], &grent.gr_gid) == 0) {
if (get_gid(grpfields[2], &grent.gr_gid) == -1) {
return NULL;
}
grent.gr_mem = list (grpfields[3]);
+1 -1
View File
@@ -97,7 +97,7 @@ struct passwd *sgetpwent (const char *buf)
if (get_uid (fields[2], &pwent.pw_uid) == 0) {
return NULL;
}
if (get_gid (fields[3], &pwent.pw_gid) == 0) {
if (get_gid(fields[3], &pwent.pw_gid) == -1) {
return NULL;
}
pwent.pw_gecos = fields[4];