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.
if (errno == EAGAIN)
return 0;
if (errno == EAGAIN)
return 0;
- if (errno != -EMSGSIZE)
fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (fd < 0)
fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (fd < 0)
if (!category || streq(category, "seat")) {
k = inotify_add_watch(fd, "/run/systemd/seats/", IN_MOVED_TO|IN_DELETE);
if (!category || streq(category, "seat")) {
k = inotify_add_watch(fd, "/run/systemd/seats/", IN_MOVED_TO|IN_DELETE);
if (close(fd) >= 0)
break;
if (close(fd) >= 0)
break;
truncate_nl(line);
local = streq(line, "LOCAL");
truncate_nl(line);
local = streq(line, "LOCAL");
- } else if (errno != -ENOENT)
+ } else if (errno != ENOENT)
return -errno;
return local;
return -errno;
return local;
return state;
r = unit_file_can_install(&paths, root_dir, path, true);
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;
return r;
else if (r > 0)
return UNIT_FILE_DISABLED;
errno = 0;
if (sscanf(s, "%ms %u", &sfamily, &group) < 1)
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)
family = netlink_family_from_string(sfamily);
if (family < 0)
errno = 0;
p = getpwuid(u);
if (!p)
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;
if (!path_is_absolute(p->pw_dir))
return -EINVAL;
r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
if (r) {
log_error("Failed to write to "INIT_FIFO": %m");
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;