Skip to content

Commit feffd1d

Browse files
committed
gtk.cfg: the data of g_thread_new and g_thread_try_new is not const
direction="in" on the gpointer data argument made cppcheck suggest a pointer to const (constVariablePointer/constParameterPointer) for the data, although the thread function gets it as a non-const gpointer.
1 parent 648c6e3 commit feffd1d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎cfg/gtk.cfg‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8399,7 +8399,7 @@
83998399
<not-null/>
84008400
<not-uninit/>
84018401
</arg>
8402-
<arg nr="3" direction="in"/>
8402+
<arg nr="3"/>
84038403
</function>
84048404
<!-- GThread * g_thread_try_new (const gchar *name, GThreadFunc func, gpointer data, GError **error); -->
84058405
<function name="g_thread_try_new">
@@ -8413,7 +8413,7 @@
84138413
<not-null/>
84148414
<not-uninit/>
84158415
</arg>
8416-
<arg nr="3" direction="in"/>
8416+
<arg nr="3"/>
84178417
<arg nr="4" direction="out"/>
84188418
</function>
84198419
<!-- gpointer g_thread_join (GThread *thread); -->

‎test/cfg/gtk.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,17 @@ void g_thread_join_parameter_test(GThread *thread)
806806
g_thread_join(thread);
807807
}
808808

809+
// The thread function gets the data as a non-const gpointer.
810+
void g_thread_data_test(int *data)
811+
{
812+
GThread *thread = g_thread_new("test", thread_func, data);
813+
g_thread_join(thread);
814+
815+
GThread *thread_try = g_thread_try_new("test", thread_func, data, NULL);
816+
if (thread_try)
817+
g_thread_join(thread_try);
818+
}
819+
809820
void g_thread_not_joined_test(void)
810821
{
811822
GThread *thread = g_thread_new("test", thread_func, NULL);

0 commit comments

Comments
 (0)