summaryrefslogtreecommitdiffstats
path: root/lib/get_uid.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/get_uid.c')
-rw-r--r--lib/get_uid.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/get_uid.c b/lib/get_uid.c
index 50f9922..77fe966 100644
--- a/lib/get_uid.c
+++ b/lib/get_uid.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_uid (const char *uidstr, uid_t *uid)
+
+int
+get_uid(const char *uidstr, uid_t *uid)
{
- long long int val;
- char *endptr;
+ char *end;
+ long long val;
errno = 0;
- val = strtoll (uidstr, &endptr, 10);
+ val = strtoll(uidstr, &end, 10);
if ( ('\0' == *uidstr)
- || ('\0' != *endptr)
- || (ERANGE == errno)
+ || ('\0' != *end)
+ || (0 != errno)
|| (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
- return 0;
+ return -1;
}
- *uid = (uid_t)val;
- return 1;
+ *uid = val;
+ return 0;
}