Code was testing for ERANGE errno only in some places. In other places it didn't do any errno checking at all. Unify strto* result testing by treating any non zero errno as failure. Signed-off-by: Arkadiusz Miśkiewicz <arekm@xxxxxxxx> --- libxcmd/input.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libxcmd/input.c b/libxcmd/input.c index c06b5b8..d72dff3 100644 --- a/libxcmd/input.c +++ b/libxcmd/input.c @@ -153,8 +153,9 @@ cvtnum( char *sp; int c; + errno = 0; i = strtoll(s, &sp, 0); - if (i == 0 && sp == s) + if (errno || (i == 0 && sp == s)) return -1LL; if (*sp == '\0') return i; @@ -237,8 +238,9 @@ cvttime( unsigned long i; char *sp; + errno = 0; i = strtoul(s, &sp, 0); - if (i == 0 && sp == s) + if (errno || (i == 0 && sp == s)) return 0; if (*sp == '\0') return i; @@ -344,10 +346,10 @@ prid_from_string( * Allow either a full numeric or a valid projectname, even * if it starts with a digit. */ + errno = 0; prid_long = strtoul(project, &sp, 10); if (*project != '\0' && *sp == '\0') { - if ((prid_long == ULONG_MAX && errno == ERANGE) - || (prid_long > (prid_t)-1)) + if (errno || (prid_long > (prid_t)-1)) return -1; return (prid_t)prid_long; } @@ -365,10 +367,10 @@ uid_from_string( unsigned long uid_long; char *sp; + errno = 0; uid_long = strtoul(user, &sp, 10); if (sp != user) { - if ((uid_long == ULONG_MAX && errno == ERANGE) - || (uid_long > (uid_t)-1)) + if (errno || (uid_long > (uid_t)-1)) return -1; return (uid_t)uid_long; } @@ -386,10 +388,10 @@ gid_from_string( unsigned long gid_long; char *sp; + errno = 0; gid_long = strtoul(group, &sp, 10); if (sp != group) { - if ((gid_long == ULONG_MAX && errno == ERANGE) - || (gid_long > (gid_t)-1)) + if (errno || (gid_long > (gid_t)-1)) return -1; return (gid_t)gid_long; } -- 2.0.1 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs