[PATCH 21.11] examples/performance-thread: fix build with GCC 12

Kevin Traynor ktraynor at redhat.com
Wed Aug 24 11:58:16 CEST 2022


[1/2] Compiling C object examples/dpdk-pthrea...
formance-thread_pthread_shim_pthread_shim.c.o
../examples/performance-thread/pthread_shim/pthread_shim.c:
In function ‘pthread_setspecific’:
../examples/performance-thread/pthread_shim/pthread_shim.c:592:27:
warning: ‘data’ may be used uninitialized [-Wmaybe-uninitialized]
592 |    int rv =  lthread_setspecific((unsigned int)key, data);
    |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../examples/performance-thread/pthread_shim/pthread_shim.c:589:56:
note: accessing argument 2 of a function declared with attribute
‘access (none, 2)’
589 | int pthread_setspecific(pthread_key_t key, const void *data)
    |                                            ~~~~~~~~~~~~^~~~

This is a false positive as pthread_setspecific() does not read from
the (const void *) so we can squash the warning.

performance-thread example is already removed from DPDK main branch.

Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
---
 examples/performance-thread/pthread_shim/pthread_shim.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c
index bbc076584b..a44cb8244d 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.c
+++ b/examples/performance-thread/pthread_shim/pthread_shim.c
@@ -587,4 +587,9 @@ pthread_t pthread_self(void)
 }
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
 int pthread_setspecific(pthread_key_t key, const void *data)
 {
@@ -596,4 +601,8 @@ int pthread_setspecific(pthread_key_t key, const void *data)
 }
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
+#pragma GCC diagnostic pop
+#endif
+
 int pthread_spin_init(pthread_spinlock_t *a, int b)
 {
-- 
2.37.2



More information about the stable mailing list