Use G_LIKELY without surrounding parentheses in g_assert() and
authorMatthias Clasen <matthiasc@src.gnome.org>
Wed, 27 Nov 2002 18:50:34 +0000 (18:50 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 27 Nov 2002 18:50:34 +0000 (18:50 +0000)
* glib/gmessages.h: Use G_LIKELY without surrounding parentheses
in g_assert() and g_return_[val]_if_fail() so that we always trigger
the gcc warning about "assignment used as truth value".

* glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gmacros.h
glib/gmessages.h

index b9deb2b..f14ee9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index b9deb2b..f14ee9b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Matthias Clasen  <maclas@gmx.de>
+
+       * glib/gmessages.h: Use G_LIKELY without surrounding parentheses 
+       in g_assert() and g_return_[val]_if_fail() so that we always trigger
+       the gcc warning about "assignment used as truth value".
+
+       * glib/gmacros.h: Always put parentheses in G_LIKELY and G_UNLIKELY.
+
 2002-11-26  Matthias Clasen  <maclas@gmx.de>
 
        * glib/gmessages.h: Only use G_LIKELY in g_assert() and 
index 20555e3..0576140 100644 (file)
       _g_boolean_var_ = 0;                      \
    _g_boolean_var_;                             \
 })
-#define G_LIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 1)
-#define G_UNLIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 0)
+#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1))
+#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0))
 #else
 #define G_LIKELY(expr) (expr)
 #define G_UNLIKELY(expr) (expr)
index da3f15b..cc36388 100644 (file)
@@ -198,11 +198,11 @@ GPrintFunc      g_set_printerr_handler  (GPrintFunc      func);
 
 #else /* !G_DISABLE_ASSERT */
 
-#if defined(__GNUC__) && (__GNUC__ > 2)  && defined(__OPTIMIZE__)
+#ifdef __GNUC__
 
 #define g_assert(expr)                 G_STMT_START{           \
-     if (!G_LIKELY (expr))                                     \
-       g_log (G_LOG_DOMAIN,                                    \
+     if G_LIKELY(expr) { } else                                \
+        g_log (G_LOG_DOMAIN,                                   \
              G_LOG_LEVEL_ERROR,                                \
              "file %s: line %d (%s): assertion failed: (%s)",  \
              __FILE__,                                         \
@@ -250,10 +250,10 @@ GPrintFunc      g_set_printerr_handler  (GPrintFunc      func);
 
 #else /* !G_DISABLE_CHECKS */
 
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#ifdef __GNUC__
 
 #define g_return_if_fail(expr)         G_STMT_START{                   \
-     if (!G_LIKELY (expr))                                             \
+     if G_LIKELY(expr) { } else                                        \
        {                                                               \
         g_log (G_LOG_DOMAIN,                                           \
                G_LOG_LEVEL_CRITICAL,                                   \
@@ -266,7 +266,7 @@ GPrintFunc      g_set_printerr_handler  (GPrintFunc      func);
        };                              }G_STMT_END
 
 #define g_return_val_if_fail(expr,val) G_STMT_START{                   \
-     if (!G_LIKELY (expr))                                             \
+     if G_LIKELY(expr) { } else                                                \
        {                                                               \
         g_log (G_LOG_DOMAIN,                                           \
                G_LOG_LEVEL_CRITICAL,                                   \