]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
_dbus_get_is_errno_eagain_or_ewouldblock: Avoid warning
authorDavid King <dking@redhat.com>
Fri, 12 Oct 2018 15:20:39 +0000 (16:20 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 18 Oct 2018 11:34:09 +0000 (12:34 +0100)
EAGAIN and EWOULDBLOCK are documented to possibly be numerically equal,
for instance in errno(3), and a simple logical OR check will trigger the
-Wlogical-op warning of GCC. The GCC developers consider the warning to
work as-designed in this case:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Avoid such a warning by explicitly checking if the values are identical.

Fixes: https://gitlab.freedesktop.org/dbus/dbus/issues/225
Signed-off-by: David King <dking@redhat.com>
Reviewed-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-sysdeps-unix.c

index 1b20337317fd62bdc74c18c82baaeca9869680d5..2b1c60691cdaf2989c5b171175f60c7b8cc5db8a 100644 (file)
@@ -4604,7 +4604,15 @@ _dbus_daemon_unpublish_session_bus_address (void)
 dbus_bool_t
 _dbus_get_is_errno_eagain_or_ewouldblock (int e)
 {
+  /* Avoid the -Wlogical-op GCC warning, which can be triggered when EAGAIN and
+   * EWOULDBLOCK are numerically equal, which is permitted as described by
+   * errno(3).
+   */
+#if EAGAIN == EWOULDBLOCK
+  return e == EAGAIN;
+#else
   return e == EAGAIN || e == EWOULDBLOCK;
+#endif
 }
 
 /**