-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: silence an infinite-loop error in
g_error()
Due to some improvements to GCC's static analyzer, the intentional loop in `g_error()` throws an error in the CI. Add `V_GNUC_BEGIN_IGNORE_INFINITE_LOOP` (and matching `END`) macro to silence false positives from `g_error()`.
- Loading branch information
1 parent
14ce9c7
commit 420d061
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,5 +204,40 @@ void valent_trace_mark (const char *strfunc, | |
# define VALENT_JSON(_node, _ctx) G_STMT_START { } G_STMT_END | ||
#endif | ||
|
||
/** | ||
* V_GNUC_BEGIN_IGNORE_INFINITE_LOOP: (skip) | ||
* | ||
* Tells gcc (if it is a new enough version) to temporarily stop emitting | ||
* warnings when functions employ an infinite loop. This is useful for functions | ||
* that do so intentionally, such as [[email protected]]. | ||
* | ||
* Since: 1.0 | ||
*/ | ||
|
||
/** | ||
* V_GNUC_END_IGNORE_INFINITE_LOOP: (skip) | ||
* | ||
* Undoes the effect of [[email protected]_GNUC_BEGIN_IGNORE_INFINITE_LOOP], telling gcc | ||
* to begin outputting warnings again (assuming those warnings had been enabled | ||
* to begin with). | ||
* | ||
* Since: 1.0 | ||
*/ | ||
|
||
#if G_GNUC_CHECK_VERSION(14, 0) | ||
#define V_GNUC_BEGIN_IGNORE_INFINITE_LOOP \ | ||
G_STMT_START { \ | ||
_Pragma("GCC diagnostic push") \ | ||
_Pragma("GCC diagnostic ignored \"-Wanalyzer-infinite-loop\"") \ | ||
} G_STMT_END | ||
#define V_GNUC_END_IGNORE_INFINITE_LOOP \ | ||
G_STMT_START { \ | ||
_Pragma("GCC diagnostic pop") \ | ||
} G_STMT_END | ||
#else | ||
#define V_GNUC_BEGIN_IGNORE_INFINITE_LOOP G_STMT_START { } G_STMT_END | ||
#define V_GNUC_END_IGNORE_INFINITE_LOOP G_STMT_START { } G_STMT_END | ||
#endif | ||
|
||
G_END_DECLS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters