summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-21 23:24:30 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-22 15:40:37 -0400
commit48deb058b62b7245d59344134a126a3d5bdb5b58 (patch)
treeda4091e32541ba73cea938a9625682378668bc00 /src
parent6fe391c56d3f4231576ccc9d62d2000f37640a92 (diff)
util: workaround two gcc warnings
gcc does not know that errno cannot be negative, and warns about unitialized variables later on. Kill the warnings by returning -errno only after checking that errno is positive.
Diffstat (limited to 'src')
-rw-r--r--src/shared/util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index bc6e035c60..260c100868 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -290,7 +290,7 @@ int safe_atou(const char *s, unsigned *ret_u) {
l = strtoul(s, &x, 0);
if (!x || x == s || *x || errno)
- return errno ? -errno : -EINVAL;
+ return errno > 0 ? -errno : -EINVAL;
if ((unsigned long) (unsigned) l != l)
return -ERANGE;
@@ -310,7 +310,7 @@ int safe_atoi(const char *s, int *ret_i) {
l = strtol(s, &x, 0);
if (!x || x == s || *x || errno)
- return errno ? -errno : -EINVAL;
+ return errno > 0 ? -errno : -EINVAL;
if ((long) (int) l != l)
return -ERANGE;