summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-28 09:24:15 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-29 10:12:41 -0400
commit8333c77edf8fd1654cd96f3f6ee0f078dd64b58b (patch)
tree135da27f10763e512868c34155891864877f6622 /src/shared
parent0db809489fd88a320ae1023ffe36a9965e9a91b2 (diff)
Always use errno > 0 to help gcc
gcc thinks that errno might be negative, and functions could return something positive on error (-errno). Should not matter in practice, but makes an -O4 build much quieter.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/calendarspec.c4
-rw-r--r--src/shared/fileio.c2
-rw-r--r--src/shared/socket-util.c2
-rw-r--r--src/shared/time-util.c4
-rw-r--r--src/shared/util.c6
-rw-r--r--src/shared/util.h2
6 files changed, 10 insertions, 10 deletions
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index cc680779b5..13f70d8e72 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -391,7 +391,7 @@ static int prepend_component(const char **p, CalendarComponent **c) {
errno = 0;
value = strtoul(*p, &e, 10);
- if (errno != 0)
+ if (errno > 0)
return -errno;
if (e == *p)
return -EINVAL;
@@ -400,7 +400,7 @@ static int prepend_component(const char **p, CalendarComponent **c) {
if (*e == '/') {
repeat = strtoul(e+1, &ee, 10);
- if (errno != 0)
+ if (errno > 0)
return -errno;
if (ee == e+1)
return -EINVAL;
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 0eca4416f8..1c7d485130 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -364,7 +364,7 @@ int write_env_file(const char *fname, char **l) {
fflush(f);
if (ferror(f)) {
- if (errno != 0)
+ if (errno > 0)
r = -errno;
else
r = -EIO;
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index f6ddea3183..53457886e2 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -68,7 +68,7 @@ int socket_address_parse(SocketAddress *a, const char *s) {
errno = 0;
if (inet_pton(AF_INET6, n, &a->sockaddr.in6.sin6_addr) <= 0) {
free(n);
- return errno != 0 ? -errno : -EINVAL;
+ return errno > 0 ? -errno : -EINVAL;
}
free(n);
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index e192d5ef58..0c6deb66f4 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -547,7 +547,7 @@ int parse_usec(const char *t, usec_t *usec) {
errno = 0;
l = strtoll(p, &e, 10);
- if (errno != 0)
+ if (errno > 0)
return -errno;
if (l < 0)
@@ -627,7 +627,7 @@ int parse_nsec(const char *t, nsec_t *nsec) {
errno = 0;
l = strtoll(p, &e, 10);
- if (errno != 0)
+ if (errno > 0)
return -errno;
if (l < 0)
diff --git a/src/shared/util.c b/src/shared/util.c
index 2241b79859..7281cc8ab8 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2265,7 +2265,7 @@ int parse_bytes(const char *t, off_t *bytes) {
errno = 0;
l = strtoll(p, &e, 10);
- if (errno != 0)
+ if (errno > 0)
return -errno;
if (l < 0)
@@ -4191,7 +4191,7 @@ int get_user_creds(
}
if (!p)
- return errno != 0 ? -errno : -ESRCH;
+ return errno > 0 ? -errno : -ESRCH;
if (uid)
*uid = p->pw_uid;
@@ -4272,7 +4272,7 @@ int get_group_creds(const char **groupname, gid_t *gid) {
}
if (!g)
- return errno != 0 ? -errno : -ESRCH;
+ return errno > 0 ? -errno : -ESRCH;
if (gid)
*gid = g->gr_gid;
diff --git a/src/shared/util.h b/src/shared/util.h
index aefde5f85a..485733f650 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -595,7 +595,7 @@ int create_tmp_dir(char template[], char** dir_name);
#define FOREACH_DIRENT(de, d, on_error) \
for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d)) \
if (!de) { \
- if (errno != 0) { \
+ if (errno > 0) { \
on_error; \
} \
break; \