aboutsummaryrefslogtreecommitdiffstats
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
parent53d3a99cccf08016eff0351884e7e86a658dffd6 (diff)
downloadplatform_external_kmod-a6ede6c7ad46b5e2b8eddddca5590c0b745b045a.tar.gz
platform_external_kmod-a6ede6c7ad46b5e2b8eddddca5590c0b745b045a.tar.bz2
platform_external_kmod-a6ede6c7ad46b5e2b8eddddca5590c0b745b045a.zip
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.
-rw-r--r--shared/util.c8
-rw-r--r--testsuite/test-testsuite.c2
2 files changed, 5 insertions, 5 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;
diff --git a/testsuite/test-testsuite.c b/testsuite/test-testsuite.c
index e6867b5..56e7360 100644
--- a/testsuite/test-testsuite.c
+++ b/testsuite/test-testsuite.c
@@ -97,7 +97,7 @@ static int testsuite_rootfs_open(const struct test *t)
int r = read(fd, buf + done, sizeof(buf) - 1 - done);
if (r == 0)
break;
- if (r == -EWOULDBLOCK || r == -EAGAIN)
+ if (r == -EAGAIN)
continue;
done += r;