summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2016-08-10 12:42:12 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2016-08-10 12:45:36 -0300
commita6ede6c7ad46b5e2b8eddddca5590c0b745b045a (patch)
treeb146cda66004e346e8665b8fe03bfbd066780597 /shared
parent53d3a99cccf08016eff0351884e7e86a658dffd6 (diff)
downloadkmod-a6ede6c7ad46b5e2b8eddddca5590c0b745b045a.tar.gz
util: fix warning of equal values on logical OR
shared/util.c: In function ‘read_str_safe’: shared/util.c:211:24: warning: logical ‘or’ of equal expressions [-Wlogical-op] if (errno == EAGAIN || errno == EWOULDBLOCK || ^~ shared/util.c: In function ‘write_str_safe’: shared/util.c:237:24: warning: logical ‘or’ of equal expressions [-Wlogical-op] if (errno == EAGAIN || errno == EWOULDBLOCK || ^~ This is because EAGAIN and EWOULDBLOCK have the same value. Prefer EAGAIN, but add a static assert to catch if it's not the same in another architecture.
Diffstat (limited to 'shared')
-rw-r--r--shared/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/shared/util.c b/shared/util.c
index 1a2b17c..9de080a 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -49,6 +49,8 @@ static const struct kmod_ext {
{ }
};
+assert_cc(EAGAIN == EWOULDBLOCK);
+
/* string handling functions and memory allocations */
/* ************************************************************************ */
@@ -208,8 +210,7 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen)
todo -= r;
done += r;
} else {
- if (errno == EAGAIN || errno == EWOULDBLOCK ||
- errno == EINTR)
+ if (errno == EAGAIN || errno == EINTR)
continue;
else
return -errno;
@@ -234,8 +235,7 @@ ssize_t write_str_safe(int fd, const char *buf, size_t buflen)
todo -= r;
done += r;
} else {
- if (errno == EAGAIN || errno == EWOULDBLOCK ||
- errno == EINTR)
+ if (errno == EAGAIN || errno == EINTR)
continue;
else
return -errno;