summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-11 18:57:42 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-11 19:13:18 -0400
commitbcb161b0230fdd1faf9176f95fee76a7db6afd59 (patch)
treec3ba8c1cf806c961842bd51b42c6e8f9b7b59c6e /src/shared
parent0ad4e1a872e789c77828d4c4825a56241103650c (diff)
errno is positive
Make sure we compare errno against positive error codes. The ones in hwclock.c and install.c can have an impact, the rest are unlikely to be hit or in code that isn't widely used. Also check that errno > 0, to help gcc know that we are returning a negative error code.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/hwclock.c2
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/socket-util.c2
-rw-r--r--src/shared/util.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/hwclock.c b/src/shared/hwclock.c
index 488c30e93f..55b0fa8a0f 100644
--- a/src/shared/hwclock.c
+++ b/src/shared/hwclock.c
@@ -190,7 +190,7 @@ int hwclock_is_localtime(void) {
truncate_nl(line);
local = streq(line, "LOCAL");
- } else if (errno != -ENOENT)
+ } else if (errno != ENOENT)
return -errno;
return local;
diff --git a/src/shared/install.c b/src/shared/install.c
index 9e870392f2..b368b9f9ab 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1637,7 +1637,7 @@ UnitFileState unit_file_get_state(
return state;
r = unit_file_can_install(&paths, root_dir, path, true);
- if (r < 0 && errno != -ENOENT)
+ if (r < 0 && errno != ENOENT)
return r;
else if (r > 0)
return UNIT_FILE_DISABLED;
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 53457886e2..4933fe08e2 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -204,7 +204,7 @@ int socket_address_parse_netlink(SocketAddress *a, const char *s) {
errno = 0;
if (sscanf(s, "%ms %u", &sfamily, &group) < 1)
- return errno ? -errno : -EINVAL;
+ return errno > 0 ? -errno : -EINVAL;
family = netlink_family_from_string(sfamily);
if (family < 0)
diff --git a/src/shared/util.c b/src/shared/util.c
index 57943b6411..5827f6c7a1 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5259,7 +5259,7 @@ int get_home_dir(char **_h) {
errno = 0;
p = getpwuid(u);
if (!p)
- return errno ? -errno : -ESRCH;
+ return errno > 0 ? -errno : -ESRCH;
if (!path_is_absolute(p->pw_dir))
return -EINVAL;