summaryrefslogtreecommitdiffstats
path: root/lib/get_gid.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/get_gid.c')
-rw-r--r--lib/get_gid.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/get_gid.c b/lib/get_gid.c
index cbcd6f4..2420137 100644
--- a/lib/get_gid.c
+++ b/lib/get_gid.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <config.h>
#ident "$Id$"
@@ -11,21 +12,23 @@
#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 int val;
- char *endptr;
+ char *end;
+ long long val;
errno = 0;
- val = strtoll (gidstr, &endptr, 10);
+ val = strtoll(gidstr, &end, 10);
if ( ('\0' == *gidstr)
- || ('\0' != *endptr)
- || (ERANGE == errno)
+ || ('\0' != *end)
+ || (0 != errno)
|| (/*@+longintegral@*/val != (gid_t)val)/*@=longintegral@*/) {
- return 0;
+ return -1;
}
- *gid = (gid_t)val;
- return 1;
+ *gid = val;
+ return 0;
}