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:
committed by
Serge Hallyn
parent
ea253cb275
commit
470baeabbd
+6
-3
@@ -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
@@ -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
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user