tree-wide: check if errno is greater then zero
gcc is confused by the common idiom of
return errno ? -errno : -ESOMETHING
and thinks a positive value may be returned. Replace this condition
with errno > 0 to help gcc and avoid many spurious warnings. I filed
a gcc rfe a long time ago, but it hard to say if it will ever be
implemented [1].
Both conventions were used in the codebase, this change makes things
more consistent. This is a follow up to bcb161b023
.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
This commit is contained in:
parent
d9a090b995
commit
f5e5c28f42
|
@ -93,7 +93,7 @@ int cg_read_pid(FILE *f, pid_t *_pid) {
|
|||
if (feof(f))
|
||||
return 0;
|
||||
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
}
|
||||
|
||||
if (ul <= 0)
|
||||
|
|
|
@ -165,7 +165,7 @@ int read_one_line_file(const char *fn, char **line) {
|
|||
if (!fgets(t, sizeof(t), f)) {
|
||||
|
||||
if (ferror(f))
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
t[0] = 0;
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ int fflush_and_check(FILE *f) {
|
|||
fflush(f);
|
||||
|
||||
if (ferror(f))
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ int glob_exists(const char *path) {
|
|||
if (k == GLOB_NOSPACE)
|
||||
return -ENOMEM;
|
||||
if (k != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return !strv_isempty(g.gl_pathv);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int glob_extend(char ***strv, const char *path) {
|
|||
if (k == GLOB_NOSPACE)
|
||||
return -ENOMEM;
|
||||
if (k != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
if (strv_isempty(g.gl_pathv))
|
||||
return -ENOENT;
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
|
|||
errno = 0;
|
||||
if (!inet_ntop(family, u, x, l)) {
|
||||
free(x);
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
}
|
||||
|
||||
*ret = x;
|
||||
|
@ -236,7 +236,7 @@ int in_addr_from_string(int family, const char *s, union in_addr_union *ret) {
|
|||
|
||||
errno = 0;
|
||||
if (inet_pton(family, s, ret) <= 0)
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
|
|||
|
||||
errno = 0;
|
||||
if (!fgets(line, sizeof(line), f))
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
truncate_nl(line);
|
||||
|
||||
|
@ -212,7 +212,7 @@ int ask_string(char **ret, const char *text, ...) {
|
|||
|
||||
errno = 0;
|
||||
if (!fgets(line, sizeof(line), stdin))
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
if (!endswith(line, "\n"))
|
||||
putchar('\n');
|
||||
|
|
|
@ -2319,7 +2319,7 @@ int exec_context_load_environment(Unit *unit, const ExecContext *c, char ***l) {
|
|||
continue;
|
||||
|
||||
strv_free(r);
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
}
|
||||
count = pglob.gl_pathc;
|
||||
if (count == 0) {
|
||||
|
|
|
@ -502,7 +502,7 @@ static int write_root_shadow(const char *path, const struct spwd *p) {
|
|||
|
||||
errno = 0;
|
||||
if (putspent(p, f) != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return fflush_and_check(f);
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ static int verify_tty(const char *name) {
|
|||
|
||||
errno = 0;
|
||||
if (isatty(fd) <= 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ int aufs_resolve(const char *path) {
|
|||
errno = 0;
|
||||
r = nftw(path, nftw_cb, 64, FTW_MOUNT|FTW_PHYS|FTW_ACTIONRETVAL);
|
||||
if (r == FTW_STOP)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -539,7 +539,7 @@ static int read_next_mapping(const char* filename,
|
|||
if (!fgets(line, sizeof(line), f)) {
|
||||
|
||||
if (ferror(f))
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user) {
|
|||
errno = 0;
|
||||
p = getpwuid(uid);
|
||||
if (!p)
|
||||
return errno ? -errno : -ENOENT;
|
||||
return errno > 0 ? -errno : -ENOENT;
|
||||
|
||||
return manager_add_user(m, uid, p->pw_gid, p->pw_name, _user);
|
||||
}
|
||||
|
|
|
@ -1111,7 +1111,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
|
|||
errno = 0;
|
||||
pw = getpwuid(uid);
|
||||
if (!pw)
|
||||
return errno ? -errno : -ENOENT;
|
||||
return errno > 0 ? -errno : -ENOENT;
|
||||
|
||||
r = bus_verify_polkit_async(
|
||||
message,
|
||||
|
|
|
@ -280,7 +280,7 @@ static int putgrent_with_members(const struct group *gr, FILE *group) {
|
|||
|
||||
errno = 0;
|
||||
if (putgrent(&t, group) != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ static int putgrent_with_members(const struct group *gr, FILE *group) {
|
|||
|
||||
errno = 0;
|
||||
if (putgrent(gr, group) != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ static int putsgent_with_members(const struct sgrp *sg, FILE *gshadow) {
|
|||
|
||||
errno = 0;
|
||||
if (putsgent(&t, gshadow) != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ static int putsgent_with_members(const struct sgrp *sg, FILE *gshadow) {
|
|||
|
||||
errno = 0;
|
||||
if (putsgent(sg, gshadow) != 0)
|
||||
return errno ? -errno : -EIO;
|
||||
return errno > 0 ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) {
|
|||
errno = 0;
|
||||
pl = blkid_probe_get_partitions(pr);
|
||||
if (!pl)
|
||||
return errno ? -errno : -ENOMEM;
|
||||
return errno > 0 ? -errno : -ENOMEM;
|
||||
|
||||
nvals = blkid_partlist_numof_partitions(pl);
|
||||
for (i = 0; i < nvals; i++) {
|
||||
|
|
Loading…
Reference in a new issue