summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/libsystemd-bus/bus-kernel.c2
-rw-r--r--src/login/sd-login.c2
-rw-r--r--src/readahead/sd-readahead.c2
-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
-rw-r--r--src/systemctl/systemctl.c2
8 files changed, 8 insertions, 8 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index e5e3536ad0..b83dfcbc27 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -339,7 +339,7 @@ int bus_kernel_read_message(sd_bus *bus, sd_bus_message **m) {
if (errno == EAGAIN)
return 0;
- if (errno != -EMSGSIZE)
+ if (errno != EMSGSIZE)
return -errno;
sz *= 2;
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 7513f76cb3..f433e3e80b 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -730,7 +730,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) {
fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (fd < 0)
- return errno;
+ return -errno;
if (!category || streq(category, "seat")) {
k = inotify_add_watch(fd, "/run/systemd/seats/", IN_MOVED_TO|IN_DELETE);
diff --git a/src/readahead/sd-readahead.c b/src/readahead/sd-readahead.c
index 4a096eed42..675d82cdd1 100644
--- a/src/readahead/sd-readahead.c
+++ b/src/readahead/sd-readahead.c
@@ -65,7 +65,7 @@ static int touch(const char *path) {
if (close(fd) >= 0)
break;
- if (errno != -EINTR)
+ if (errno != EINTR)
return -errno;
}
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;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a950605503..1c7edd5a58 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5260,7 +5260,7 @@ static int talk_initctl(void) {
r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
if (r) {
log_error("Failed to write to "INIT_FIFO": %m");
- return errno ? -errno : -EIO;
+ return errno > 0 ? -errno : -EIO;
}
return 1;