]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Silence warnings from -Wlogical-op.
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 16 Jun 2016 19:46:02 +0000 (22:46 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 16 Jun 2016 19:46:02 +0000 (22:46 +0300)
Thanks to Evan Nemerson.

src/xz/file_io.c

index 69cf6326a1cdba176b23846dc311cbc1dadd4947..2ca188bd98d05467d531724ae169cfb3aef643af 100644 (file)
@@ -45,6 +45,14 @@ static bool warn_fchown;
 #      define O_NOCTTY 0
 #endif
 
+// Using this macro to silence a warning from gcc -Wlogical-op.
+#if EAGAIN == EWOULDBLOCK
+#      define IS_EAGAIN_OR_EWOULDBLOCK(e) ((e) == EAGAIN)
+#else
+#      define IS_EAGAIN_OR_EWOULDBLOCK(e) \
+               ((e) == EAGAIN || (e) == EWOULDBLOCK)
+#endif
+
 
 typedef enum {
        IO_WAIT_MORE,    // Reading or writing is possible.
@@ -1102,7 +1110,7 @@ io_read(file_pair *pair, io_buf *buf_union, size_t size)
                        }
 
 #ifndef TUKLIB_DOSLIKE
-                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
+                       if (IS_EAGAIN_OR_EWOULDBLOCK(errno)) {
                                const io_wait_ret ret = io_wait(pair,
                                                mytime_get_flush_timeout(),
                                                true);
@@ -1190,7 +1198,7 @@ io_write_buf(file_pair *pair, const uint8_t *buf, size_t size)
                        }
 
 #ifndef TUKLIB_DOSLIKE
-                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
+                       if (IS_EAGAIN_OR_EWOULDBLOCK(errno)) {
                                if (io_wait(pair, -1, false) == IO_WAIT_MORE)
                                        continue;