gtk.cfg: Add/enhance function configurations and tests. (#2101)

Add/enhance:
g_once_init_enter(), g_once_init_leave() and g_signal_emit_by_name()
This commit is contained in:
Sebastian 2019-08-20 15:00:30 +02:00 committed by GitHub
parent ef47d3d304
commit a2a874dbd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 0 deletions

View File

@ -2965,13 +2965,31 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<!-- gboolean g_once_init_enter (volatile void *location); -->
<function name="g_once_init_enter">
<leak-ignore/>
<noreturn>false</noreturn>
<returnValue type="gboolean"/>
<use-retval/>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
</function>
<!-- void g_once_init_leave (volatile void *location,
gsize result); -->
<function name="g_once_init_leave">
<leak-ignore/>
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
<valid>1:</valid>
</arg>
</function>
<function name="g_option_error_quark">
<leak-ignore/>
@ -19650,6 +19668,24 @@
<not-uninit/>
</arg>
</function>
<!-- void g_signal_emit_by_name (gpointer instance,
const gchar *detailed_signal,
...); -->
<function name="g_signal_emit_by_name">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
<strz/>
</arg>
<arg nr="variadic">
<not-uninit/>
</arg>
</function>
<define name="gchar" value="char"/>
<define name="guchar" value="unsigned char"/>
<define name="gint" value="int"/>

View File

@ -53,6 +53,12 @@ void validCode(int argInt)
GError * pGerror = g_error_new(1, -2, "a %d", 1);
g_error_free(pGerror);
static gsize init_val = 0;
if (g_once_init_enter(&init_val)) {
gsize result_val = 1;
g_once_init_leave(&init_val, result_val);
}
}
void g_malloc_test()
@ -366,3 +372,32 @@ void g_error_new_test()
printf("%p", pNew2);
// cppcheck-suppress memleak
}
void g_once_init_enter_leave_test()
{
static gsize init_val;
if (g_once_init_enter(&init_val)) {
gsize result_val = 0;
// cppcheck-suppress invalidFunctionArg
g_once_init_leave(&init_val, result_val);
}
gsize init_val2;
// cppcheck-suppress uninitvar
// cppcheck-suppress ignoredReturnValue
g_once_init_enter(&init_val2);
gsize * init_val3 = NULL;
// cppcheck-suppress nullPointer
if (g_once_init_enter(init_val3)) {
// cppcheck-suppress nullPointer
g_once_init_leave(init_val3, 1);
}
gsize * init_val4;
// cppcheck-suppress uninitvar
if (g_once_init_enter(init_val4)) {
// cppcheck-suppress uninitvar
g_once_init_leave(init_val4, 1);
}
}