]> Savannah Git Hosting - gnulib.git/commitdiff
error: Avoid -Wint-in-bool-context warning.
authorBruno Haible <bruno@clisp.org>
Sun, 28 May 2023 13:18:06 +0000 (15:18 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 28 May 2023 13:18:06 +0000 (15:18 +0200)
Reported by Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-05/msg00178.html>.

* lib/error.in.h (error, error_at_line): Use 'status != 0', since status
is expected to be an int, not a bool value.

ChangeLog
lib/error.in.h

index 0912f8e6349819256288e6c21c2ac6fa22e3d252..e3a2507c47d48603f4788d8ee7837b5c1704582a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-28  Bruno Haible  <bruno@clisp.org>
+
+       error: Avoid -Wint-in-bool-context warning.
+       Reported by Pádraig Brady in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2023-05/msg00178.html>.
+       * lib/error.in.h (error, error_at_line): Use 'status != 0', since status
+       is expected to be an int, not a bool value.
+
 2023-05-27  Bruno Haible  <bruno@clisp.org>
 
        error: Support the compiler's control flow analysis better.
index 4bf191e102f6dba2afaf2fadf45f04e05b7b1b4d..70fb1321330ce1826e938a62666d33d35540f26d 100644 (file)
@@ -69,7 +69,7 @@ _GL_CXXALIAS_RPL (error, void,
 # ifndef _GL_NO_INLINE_ERROR
 #  undef error
 #  define error(status, ...) \
-     ((rpl_error)(0, __VA_ARGS__), (status) ? exit (status) : (void)0)
+     ((rpl_error)(0, __VA_ARGS__), (status) != 0 ? exit (status) : (void)0)
 # endif
 #else
 # if ! @HAVE_ERROR@
@@ -81,7 +81,7 @@ _GL_CXXALIAS_SYS (error, void,
                   (int __status, int __errnum, const char *__format, ...));
 # ifndef _GL_NO_INLINE_ERROR
 #  define error(status, ...) \
-     ((error)(0, __VA_ARGS__), (status) ? exit (status) : (void)0)
+     ((error)(0, __VA_ARGS__), (status) != 0 ? exit (status) : (void)0)
 # endif
 #endif
 #if __GLIBC__ >= 2
@@ -105,7 +105,7 @@ _GL_CXXALIAS_RPL (error_at_line, void,
 # ifndef _GL_NO_INLINE_ERROR
 #  undef error_at_line
 #  define error_at_line(status, ...) \
-     ((rpl_error_at_line)(0, __VA_ARGS__), (status) ? exit (status) : (void)0)
+     ((rpl_error_at_line)(0, __VA_ARGS__), (status) != 0 ? exit (status) : (void)0)
 # endif
 #else
 # if ! @HAVE_ERROR_AT_LINE@
@@ -119,7 +119,7 @@ _GL_CXXALIAS_SYS (error_at_line, void,
                    unsigned int __lineno, const char *__format, ...));
 # ifndef _GL_NO_INLINE_ERROR
 #  define error_at_line(status, ...) \
-     ((error_at_line)(0, __VA_ARGS__), (status) ? exit (status) : (void)0)
+     ((error_at_line)(0, __VA_ARGS__), (status) != 0 ? exit (status) : (void)0)
 # endif
 #endif
 _GL_CXXALIASWARN (error_at_line);