Skip to content

Commit 14e71f7

Browse files
committed
gtk.cfg: Remove extra semicolons from g_return* macros
The extra semicolons caused unknownMacro errors when checking code like this: if (hadj) g_return_if_fail (GTK_IS_ADJUSTMENT (hadj)); else hadj = GTK_ADJUSTMENT (...) They were introduced in commit c0b5309, but they are not actually present in the upstream GLib macros.
1 parent 2285c1d commit 14e71f7

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

cfg/gtk.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<def format="2">
55
<define name="TRUE" value="(!FALSE)"/>
66
<define name="FALSE" value="(0)"/>
7-
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0);"/>
8-
<define name="g_return_val_if_fail(expr,val)" value="do{if(!(expr)){return (val);}}while(0);"/>
9-
<define name="g_return_if_reached()" value="do{return;}while(0);"/>
10-
<define name="g_return_val_if_reached(val)" value="do{return (val);}while(0);"/>
7+
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0)"/>
8+
<define name="g_return_val_if_fail(expr,val)" value="do{if(!(expr)){return (val);}}while(0)"/>
9+
<define name="g_return_if_reached()" value="do{return;}while(0)"/>
10+
<define name="g_return_val_if_reached(val)" value="do{return (val);}while(0)"/>
1111
<define name="G_CALLBACK(cb)" value="cb"/>
1212
<define name="GTK_SIGNAL_FUNC(f)" value="G_CALLBACK(f)"/>
1313
<define name="G_DIR_SEPARATOR_S" value="&quot;/&quot;"/>

test/cfg/gtk.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,43 @@ void gtk_widget_destroy_test() {
596596
// cppcheck-suppress mismatchAllocDealloc
597597
g_object_unref(widget);
598598
}
599+
600+
void g_return_if_fail_test(const char *s) {
601+
// cppcheck-suppress valueFlowBailout
602+
g_return_if_fail(s);
603+
604+
if (*s)
605+
// cppcheck-suppress valueFlowBailout
606+
g_return_if_fail(*s == 'a');
607+
else
608+
g_info("Test the else branch can be parsed");
609+
}
610+
611+
int g_return_val_if_fail_test(const char *s) {
612+
// cppcheck-suppress valueFlowBailout
613+
g_return_val_if_fail(s, 1);
614+
615+
if (*s)
616+
// cppcheck-suppress valueFlowBailout
617+
g_return_val_if_fail(*s == 'a', 1);
618+
else
619+
g_info("Test the else branch can be parsed");
620+
621+
return 0;
622+
}
623+
624+
void g_return_if_reached_test(const char *s) {
625+
if (s)
626+
g_return_if_reached();
627+
else
628+
g_info("Test the else branch can be parsed");
629+
}
630+
631+
int g_return_val_if_reached_test(const char *s) {
632+
if (s)
633+
g_return_val_if_reached(1);
634+
else
635+
g_info("Test the else branch can be parsed");
636+
637+
return 0;
638+
}

0 commit comments

Comments
 (0)