Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Remove the (no longer effective) empty if-branch.
Browse files Browse the repository at this point in the history
	* glib/gmessages.h (g_assert):
	(g_return_if_fail):
	(g_return_val_if_fail): Remove the (no longer effective) empty
	if-branch.

	* glib/gmacros.h: Change the definition of G_LIKELY, so that
	g_return_if_fail() and friends still trigger a gcc warning if
	the expr is an assignment.
  • Loading branch information
Matthias Clasen committed Nov 25, 2002
1 parent 129cfb8 commit 827f3c4
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 8 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-10
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-12
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-2
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-4
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-6
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog.pre-2-8
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2002-11-25 Matthias Clasen <maclas@gmx.de>

* glib/gmessages.h (g_assert):
(g_return_if_fail):
(g_return_val_if_fail): Remove the (no longer effective) empty
if-branch.

* glib/gmacros.h: Change the definition of G_LIKELY, so that
g_return_if_fail() and friends still trigger a gcc warning if
the expr is an assignment.

2002-11-23 Matthias Clasen <maclas@gmx.de>

* configure.in: Generate docs/reference/*/version.xml.
Expand Down
18 changes: 15 additions & 3 deletions glib/gmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,22 @@
* The G_LIKELY and G_UNLIKELY macros let the programmer give hints to
* the compiler about the expected result of an expression. Some compilers
* can use this information for optimizations.
*
* The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
* putting assignments in g_return_if_fail ().
*/
#if defined(__GNUC__) && (__GNUC__ > 2)
#define G_LIKELY(expr) __builtin_expect (!!(expr), 1)
#define G_UNLIKELY(expr) __builtin_expect (!!(expr), 0)
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _G_BOOLEAN_EXPR(expr) \
__extension__ ({ \
int _g_boolean_var_; \
if (expr) \
_g_boolean_var_ = 1; \
else \
_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)
#else
#define G_LIKELY(expr) expr
#define G_UNLIKELY(expr) expr
Expand Down
10 changes: 5 additions & 5 deletions glib/gmessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#ifdef __GNUC__

#define g_assert(expr) G_STMT_START{ \
if (expr) { } else \
if (!G_LIKELY (expr)) \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): assertion failed: (%s)", \
Expand Down Expand Up @@ -253,7 +253,7 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#ifdef __GNUC__

#define g_return_if_fail(expr) G_STMT_START{ \
if (G_LIKELY (expr)) { } else \
if (!G_LIKELY (expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
Expand All @@ -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)) { } else \
if (!G_LIKELY (expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
Expand Down Expand Up @@ -299,7 +299,7 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#else /* !__GNUC__ */

#define g_return_if_fail(expr) G_STMT_START{ \
if (G_LIKELY (expr)) { } else \
if (expr) { } else \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
Expand All @@ -311,7 +311,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)) { } else \
if (expr) { } else \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
Expand Down

0 comments on commit 827f3c4

Please sign in to comment.