diff mbox series

[04/12] posix/conformance/interfaces: Fix unsued-variable for testfrmw

Message ID 20211119074602.857595-5-lkml@jv-coder.de
State Accepted
Headers show
Series Fix or suppress compiler warnings in posix/conformance/interfaces | expand

Commit Message

Joerg Vehlow Nov. 19, 2021, 7:45 a.m. UTC
From: Joerg Vehlow <joerg.vehlow@aox-tech.de>

Thre is a global variable sc in testfrmw/threads_scenarii, that is used,
if the integrated main function (STD_MAIN) is used. However some tests
did not use this integrated main, but still used the variable. To be able to
get rid of all warnings, the variable is duplicated into these tests and only
defined by threads_scenarii, if STD_MAIN is defined

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
 .../conformance/interfaces/pthread_create/14-1.c              | 2 ++
 .../conformance/interfaces/pthread_create/3-2.c               | 2 ++
 .../conformance/interfaces/pthread_detach/1-2.c               | 2 ++
 .../conformance/interfaces/pthread_detach/2-2.c               | 1 +
 .../conformance/interfaces/pthread_detach/4-3.c               | 1 +
 .../conformance/interfaces/pthread_exit/6-1.c                 | 1 +
 .../conformance/interfaces/pthread_join/1-2.c                 | 2 ++
 .../conformance/interfaces/pthread_join/4-1.c                 | 1 +
 .../conformance/interfaces/pthread_join/6-3.c                 | 1 +
 .../conformance/interfaces/testfrmw/threads_scenarii.c        | 4 ++--
 10 files changed, 15 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis Nov. 19, 2021, 3:07 p.m. UTC | #1
Hi!
Applied, thanks.

But still fixing warnings in the testfrmw this way feels like we are
putting a lipstick on a pig. Large scale cleanup of the code is needed
and the warnings were really harmless in this case...
Joerg Vehlow Nov. 22, 2021, 6:48 a.m. UTC | #2
Hi Cyril,

On 11/19/2021 4:07 PM, Cyril Hrubis wrote:
> Hi!
> Applied, thanks.
>
> But still fixing warnings in the testfrmw this way feels like we are
> putting a lipstick on a pig. Large scale cleanup of the code is needed
> and the warnings were really harmless in this case...
Yes as I wrote already, I wanted to start somewhere and the warning 
clutter hid already
some warnings, that indicated real programming errors. So I wanted to 
get rid of them.
Additionally the compiler output is to be inspected, because some test 
are just compile-time tests.

A one-shot cleanup of all tests is also probably not feasible, so 
iterative cleanup with clean warnings
should be easier.

Joerg
diff mbox series

Patch

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/14-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/14-1.c
index c21860ba8..84d229afc 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/14-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/14-1.c
@@ -47,6 +47,8 @@  static volatile long sleep_time;
 /* number of pthread_create scenarios tested */
 static unsigned long count_ope;
 
+static unsigned int sc;
+
 static unsigned long long current_time_usec(void)
 {
 	struct timeval now;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c
index 433ccd8fe..3197bdf67 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c
@@ -104,6 +104,8 @@ 
 
 static sem_t semsync[2];		/* These semaphores will only be used in child process! */
 
+static unsigned int sc;
+
 /* The overflow function is used to test the stack overflow */
 static void *overflow(void *arg)
 {
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/1-2.c
index a6eb391ef..28a7e9ea9 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/1-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/1-2.c
@@ -91,6 +91,8 @@ 
 /***********************************    Real Test   *****************************************/
 /********************************************************************************************/
 
+static unsigned int sc;
+
 static void *threaded(void *arg)
 {
 	int ret = 0;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/2-2.c
index 8a406fe44..a2c5cc657 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/2-2.c
@@ -93,6 +93,7 @@ 
 /********************************************************************************************/
 
 static sem_t sem_sync;
+static unsigned int sc;
 
 static void *threaded(void *arg)
 {
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-3.c
index fc3a50bef..126f5aa82 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-3.c
@@ -61,6 +61,7 @@  static sem_t semsig1;
 static unsigned long count_sig;
 static long sleep_time;
 static sigset_t usersigs;
+static unsigned int sc;
 
 struct thestruct {
 	int sig;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/6-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/6-1.c
index b21e43d7b..639e508c2 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/6-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/6-1.c
@@ -98,6 +98,7 @@ 
 /* This will be used to control that atexit() has been called */
 static int *ctl;
 static long mf;
+static unsigned int sc;
 
 static void clnp(void)
 {
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/1-2.c
index 34c410967..25e623fdb 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/1-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/1-2.c
@@ -48,6 +48,8 @@ 
 
 #include "../testfrmw/threads_scenarii.c"
 
+static unsigned int sc;
+
 static void *threaded(void *arg)
 {
 	int ret = 0;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/4-1.c
index b7bc56eac..6b19992ba 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/4-1.c
@@ -46,6 +46,7 @@ 
 #include "../testfrmw/threads_scenarii.c"
 
 static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
+static unsigned int sc;
 
 /* 1st thread function */
 static void *threaded(void *arg PTS_ATTRIBUTE_UNUSED)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-3.c
index 7325defc3..ecf0498fa 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-3.c
@@ -56,6 +56,7 @@  static unsigned long count_sig;
 #endif
 
 static sigset_t usersigs;
+static unsigned int sc;
 
 struct thestruct {
 	int sig;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/threads_scenarii.c b/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/threads_scenarii.c
index baf30a87c..645aff604 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/threads_scenarii.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/testfrmw/threads_scenarii.c
@@ -482,10 +482,10 @@  static void scenar_fini(void)
 	}
 }
 
-static unsigned int sc;
-
 #ifdef STD_MAIN
 
+static unsigned int sc;
+
 static void *threaded(void *arg);
 
 int main(void)