Skip to content

Commit

Permalink
lib/get_uid.c: get_uid(): Reimplement in terms of a2i()
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Mar 11, 2024
1 parent 8a4f794 commit 330dd28
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions lib/get_uid.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
/*
* SPDX-FileCopyrightText: 2009 , Nicolas François
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// SPDX-FileCopyrightText: 2009, Nicolas François
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause


#include <config.h>

#ident "$Id$"

#include "atoi/a2i.h"
#include "prototypes.h"
#include "defines.h"


int
get_uid(const char *uidstr, uid_t *uid)
{
char *end;
long long val;

errno = 0;
val = strtoll(uidstr, &end, 10);
if ( ('\0' == *uidstr)
|| ('\0' != *end)
|| (0 != errno)
|| (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
return -1;
}

*uid = val;
return 0;
return a2i(uid_t, uid, uidstr, NULL, 10, type_min(uid_t), type_max(uid_t));
}

0 comments on commit 330dd28

Please sign in to comment.