From: Zbigniew Jędrzejewski-Szmek Date: Fri, 22 Mar 2013 03:24:30 +0000 (-0400) Subject: util: workaround two gcc warnings X-Git-Tag: v199~79 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=48deb058b62b7245d59344134a126a3d5bdb5b58 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. --- diff --git a/src/shared/util.c b/src/shared/util.c index bc6e035c6..260c10086 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;