tree-wide: check if errno is greater than zero (2)
Compare errno with zero in a way that tells gcc that (if the condition is true) errno is positive.
This commit is contained in:
@@ -648,7 +648,7 @@ int cg_trim(const char *controller, const char *path, bool delete_root) {
|
||||
if (nftw(fs, trim_cb, 64, FTW_DEPTH|FTW_MOUNT|FTW_PHYS) != 0) {
|
||||
if (errno == ENOENT)
|
||||
r = 0;
|
||||
else if (errno != 0)
|
||||
else if (errno > 0)
|
||||
r = -errno;
|
||||
else
|
||||
r = -EIO;
|
||||
@@ -2091,7 +2091,7 @@ int cg_kernel_controllers(Set *controllers) {
|
||||
if (feof(f))
|
||||
break;
|
||||
|
||||
if (ferror(f) && errno != 0)
|
||||
if (ferror(f) && errno > 0)
|
||||
return -errno;
|
||||
|
||||
return -EBADMSG;
|
||||
|
||||
+1
-1
@@ -481,7 +481,7 @@ int get_files_in_directory(const char *path, char ***list) {
|
||||
|
||||
errno = 0;
|
||||
de = readdir(d);
|
||||
if (!de && errno != 0)
|
||||
if (!de && errno > 0)
|
||||
return -errno;
|
||||
if (!de)
|
||||
break;
|
||||
|
||||
+11
-11
@@ -81,7 +81,7 @@ int parse_mode(const char *s, mode_t *ret) {
|
||||
|
||||
errno = 0;
|
||||
l = strtol(s, &x, 8);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -176,7 +176,7 @@ int parse_size(const char *t, uint64_t base, uint64_t *size) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoull(p, &e, 10);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (e == p)
|
||||
return -EINVAL;
|
||||
@@ -192,7 +192,7 @@ int parse_size(const char *t, uint64_t base, uint64_t *size) {
|
||||
char *e2;
|
||||
|
||||
l2 = strtoull(e, &e2, 10);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
|
||||
/* Ignore failure. E.g. 10.M is valid */
|
||||
@@ -330,7 +330,7 @@ int safe_atou(const char *s, unsigned *ret_u) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoul(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -352,7 +352,7 @@ int safe_atoi(const char *s, int *ret_i) {
|
||||
|
||||
errno = 0;
|
||||
l = strtol(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -374,7 +374,7 @@ int safe_atollu(const char *s, long long unsigned *ret_llu) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoull(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -394,7 +394,7 @@ int safe_atolli(const char *s, long long int *ret_lli) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoll(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -414,7 +414,7 @@ int safe_atou8(const char *s, uint8_t *ret) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoul(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -438,7 +438,7 @@ int safe_atou16(const char *s, uint16_t *ret) {
|
||||
|
||||
errno = 0;
|
||||
l = strtoul(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -460,7 +460,7 @@ int safe_atoi16(const char *s, int16_t *ret) {
|
||||
|
||||
errno = 0;
|
||||
l = strtol(s, &x, 0);
|
||||
if (errno != 0)
|
||||
if (errno > 0)
|
||||
return -errno;
|
||||
if (!x || x == s || *x)
|
||||
return -EINVAL;
|
||||
@@ -485,7 +485,7 @@ int safe_atod(const char *s, double *ret_d) {
|
||||
|
||||
errno = 0;
|
||||
d = strtod_l(s, &x, loc);
|
||||
if (errno != 0) {
|
||||
if (errno > 0) {
|
||||
freelocale(loc);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
|
||||
errno = 0;
|
||||
de = readdir(d);
|
||||
if (!de) {
|
||||
if (errno != 0 && ret == 0)
|
||||
if (errno > 0 && ret == 0)
|
||||
ret = -errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
+1
-1
@@ -513,7 +513,7 @@ int on_ac_power(void) {
|
||||
|
||||
errno = 0;
|
||||
de = readdir(d);
|
||||
if (!de && errno != 0)
|
||||
if (!de && errno > 0)
|
||||
return -errno;
|
||||
|
||||
if (!de)
|
||||
|
||||
Reference in New Issue
Block a user