mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
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.
This commit is contained in:
parent
0ad4e1a872
commit
bcb161b023
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -65,7 +65,7 @@ static int touch(const char *path) {
|
||||
if (close(fd) >= 0)
|
||||
break;
|
||||
|
||||
if (errno != -EINTR)
|
||||
if (errno != EINTR)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user