summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2015-05-09 10:57:54 -0700
committerJim Meyering <meyering@fb.com>2015-05-09 22:49:07 -0700
commitaa7f31fc4a3f4d0c99086660d5ff008c559d657b (patch)
tree7aa9cd1d8bc4d1300e90039a8de93cc61c1fd064 /src/system.h
parente981643ae3e57affdf3f4f6aa8bf53cf06433f17 (diff)
downloadcoreutils-aa7f31fc4a3f4d0c99086660d5ff008c559d657b.tar.xz
build: avoid a warning form gcc's new -Wlogical-op
Without this change, very recent gcc (e.g., version 6.0.0 20150509) would print the following when configured with --enable-gcc-warnings: src/copy.c:165:30: error: logical 'or' of equal expressions \ [-Werror=logical-op] && (errno == EOPNOTSUPP || errno == ENOTSUP || errno == ENOSYS)) ^ * src/system.h (is_ENOTSUP): New function. * src/copy.c (punch_hole): Use it. * src/ls.c (errno_unsupported, gobble_file): Use it.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h
index c55f6d8bd..0e25bc414 100644
--- a/src/system.h
+++ b/src/system.h
@@ -695,3 +695,17 @@ stzncpy (char *restrict dest, char const *restrict src, size_t len)
in selinux.h before libselinux-2.3 (May 2014).
When version >= 2.3 is ubiquitous remove this function. */
static inline char * se_const (char const * sctx) { return (char *) sctx; }
+
+/* Return true if ERR is ENOTSUP or EOPNOTSUPP, otherwise false.
+ This wrapper function avoids the redundant 'or'd comparison on
+ systems like Linux for which they have the same value. It also
+ avoids the gcc warning to that effect. */
+static inline bool
+is_ENOTSUP (int err)
+{
+ return err == EOPNOTSUPP
+#if ENOTSUP != EOPNOTSUPP
+ || err == ENOTSUP
+#endif
+ ;
+}