From aa7f31fc4a3f4d0c99086660d5ff008c559d657b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 9 May 2015 10:57:54 -0700 Subject: 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. --- src/system.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/system.h') 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 + ; +} -- cgit v1.2.3-54-g00ecf