diff mbox series

[05/12] posix/conformance/interfaces: Fix all unused variable warnings

Message ID 20211119074602.857595-6-lkml@jv-coder.de
State Changes Requested
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>

Either by marking them as unused or by removing them, if there is no sideffect.

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
 .../conformance/interfaces/aio_read/9-1.c                     | 3 +--
 .../conformance/interfaces/aio_write/7-1.c                    | 3 +--
 .../open_posix_testsuite/conformance/interfaces/fork/7-1.c    | 2 +-
 .../conformance/interfaces/pthread_cond_init/2-1.c            | 2 +-
 .../conformance/interfaces/pthread_exit/2-2.c                 | 2 +-
 .../conformance/interfaces/pthread_exit/3-2.c                 | 2 +-
 .../conformance/interfaces/pthread_mutex_init/3-1.c           | 4 ++--
 .../conformance/interfaces/pthread_mutex_timedlock/4-1.c      | 4 +---
 .../conformance/interfaces/pthread_mutex_timedlock/5-1.c      | 4 +---
 .../conformance/interfaces/pthread_mutex_timedlock/5-2.c      | 4 +---
 .../conformance/interfaces/pthread_mutex_timedlock/5-3.c      | 4 +---
 .../conformance/interfaces/pthread_mutex_trylock/4-3.c        | 1 -
 .../conformance/interfaces/pthread_mutex_unlock/2-1.c         | 4 ++--
 .../conformance/interfaces/pthread_mutexattr_setpshared/1-1.c | 2 --
 .../conformance/interfaces/pthread_once/4-1-buildonly.c       | 3 ++-
 15 files changed, 16 insertions(+), 28 deletions(-)

Comments

Cyril Hrubis Nov. 19, 2021, 3:23 p.m. UTC | #1
Hi!
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
> index e1ae59e3b..cd1aa0318 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
> @@ -48,7 +48,6 @@ int main(void)
>  	int i;
>  	struct aiocb aiocbs[NUM_AIOCBS];
>  	int last_req;
> -	int err;
>  	int ret;
>  
>  	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
> @@ -85,7 +84,7 @@ int main(void)
>  	}
>  
>  	for (i = 0; i < last_req - 1; i++) {
> -		err = aio_error(&aiocbs[i]);
> +		aio_error(&aiocbs[i]);
>  		ret = aio_return(&aiocbs[i]);
>  
>  	}

Looking at the test the whole loop here is pointless, can we remove it
completely?

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
> index 277573a38..52c8d7004 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
> @@ -48,7 +48,6 @@ int main(void)
>  	int i;
>  	struct aiocb aiocbs[NUM_AIOCBS];
>  	int last_req;
> -	int err;
>  	int ret;
>  
>  	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
> @@ -79,7 +78,7 @@ int main(void)
>  	}
>  
>  	for (i = 0; i < last_req - 1; i++) {
> -		err = aio_error(&aiocbs[i]);
> +		aio_error(&aiocbs[i]);
>  		ret = aio_return(&aiocbs[i]);
>  
>  	}

Here as well.

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
> index aaf1403f9..9a0b148d9 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
> @@ -51,7 +51,7 @@
>  
>  static void read_catalog(nl_catd cat, char *who)
>  {
> -	char *msg = NULL;
> +	char *msg PTS_ATTRIBUTE_UNUSED = NULL;
>  	int i, j;

I guess that in this case the test is wrong as well. It does not seem
that catgets() fails when it returns the pointer to the "not found"
string and does not even touch errno.

>  #if VERBOSE > 0
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
> index 4a60f7098..fbb7c68ff 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
> @@ -14,7 +14,7 @@
>  #include <stdio.h>
>  #include "posixtest.h"
>  
> -static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
> +static pthread_cond_t cond PTS_ATTRIBUTE_UNUSED = PTHREAD_COND_INITIALIZER;

This one looks fine.

>  int main(void)
>  {
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
> index 2fc3ff700..16c658f73 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
> @@ -92,7 +92,7 @@
>  static int global = 0;
>  static int tab[3];
>  
> -#define CLEANUP(n) static void clnp##n(void * arg)\
> +#define CLEANUP(n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\
>  {\
>  	tab[global]=n; \
>  	global++; \
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
> index 5fa6c8b50..4437ffc77 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
> @@ -94,7 +94,7 @@ static int global = 0;
>  static int tab[4];
>  static pthread_key_t tld[3];
>  
> -#define CLEANUP(n) static void clnp##n(void * arg)\
> +#define CLEANUP(n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\
>  {\
>  	tab[global]=n; \
>  	global++; \

THese two as well.

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
> index 9ee86a5db..8a9b989f1 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
> @@ -5,7 +5,7 @@
>   * of this license, see the COPYING file at the top level of this
>   * source tree.
>  
> - * Test that the macro PTHREAD_MUTEX_INITIALIZER can be sued to intiailize
> + * Test that the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize
>   * mutexes that are statically allocated.
>   *
>   */
> @@ -20,7 +20,7 @@ typedef struct my_data {
>  	int value;		/* Access protected by mutex */
>  } my_data_t;
>  
> -static my_data_t data = { PTHREAD_MUTEX_INITIALIZER, 0 };
> +static my_data_t data PTS_ATTRIBUTE_UNUSED = { PTHREAD_MUTEX_INITIALIZER, 0 };
>  
>  int main(void)
>  {

This one as well.

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
> index a7099688b..d3c0bdae9 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
> @@ -32,9 +32,7 @@ static void *f1(void *parm);
>  static int ret;			/* Save return value of
>  				   pthread_mutex_timedlock(). */
>  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
> -static time_t currsec1, currsec2;	/* Variables for saving time before
> -				   and afer locking the mutex using
> -				   pthread_mutex_timedlock(). */
> +
>  /****************************
>   *
>   * MAIN()
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
> index 077bfe76d..f51106bdf 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
> @@ -40,9 +40,7 @@ static void *f1(void *parm);
>  static int ret;			/* Save return value of
>  				   pthread_mutex_timedlock(). */
>  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
> -static time_t currsec1, currsec2;	/* Variables for saving time before
> -				   and afer locking the mutex using
> -				   pthread_mutex_timedlock(). */
> +
>  /****************************
>   *
>   * MAIN()
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
> index 0eda6e58f..afca84eed 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
> @@ -40,9 +40,7 @@ static void *f1(void *parm);
>  static int ret;			/* Save return value of
>  				   pthread_mutex_timedlock(). */
>  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
> -static time_t currsec1, currsec2;	/* Variables for saving time before
> -				   and afer locking the mutex using
> -				   pthread_mutex_timedlock(). */
> +
>  /****************************
>   *
>   * MAIN()
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
> index baf429503..a5f8b3383 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
> @@ -36,9 +36,7 @@ static void *f1(void *parm);
>  static int ret;			/* Save return value of
>  				   pthread_mutex_timedlock(). */
>  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
> -static time_t currsec1, currsec2;	/* Variables for saving time before
> -				   and afer locking the mutex using
> -				   pthread_mutex_timedlock(). */
> +
>  /****************************
>   *
>   * MAIN()

This part as well.

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
> index e7e86bfa8..2145bde8a 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
> @@ -103,7 +103,6 @@ static struct _scenar {
>  #define NSCENAR (sizeof(scenarii)/sizeof(scenarii[0]))
>  
>  static char do_it = 1;
> -static char woken = 0;
>  static unsigned long count_ope = 0;
>  #ifdef WITH_SYNCHRO
>  static sem_t semsig1;
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
> index 27f0ee3d7..39dacb73e 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
> @@ -39,13 +39,13 @@ static int value;			/* value protected by mutex */
>  
>  int main(void)
>  {
> -	int i, rc;
> +	int i;
>  	pthread_t threads[THREAD_NUM];
>  
>  	/* Create threads */
>  	fprintf(stderr, "Creating %d threads\n", THREAD_NUM);
>  	for (i = 0; i < THREAD_NUM; ++i)
> -		rc = pthread_create(&threads[i], NULL, func, NULL);
> +		pthread_create(&threads[i], NULL, func, NULL);
>  
>  	/* Wait to join all threads */
>  	for (i = 0; i < THREAD_NUM; ++i)

Well technically we should check the return value, but this is better
than it was before.

> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
> index 909b53bf4..8e8617bbd 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
> @@ -37,8 +37,6 @@
>  #include <stdio.h>
>  #include "posixtest.h"
>  
> -static pthread_mutex_t new_mutex;	/* The mutex. */
> -
>  int main(void)
>  {
>  	pthread_mutexattr_t mta;
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
> index 6e519962b..d3392f908 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
> @@ -11,5 +11,6 @@
>     */
>  
>  #include <pthread.h>
> +#include "posixtest.h"
>  
> -static pthread_once_t dummy = PTHREAD_ONCE_INIT;
> +static pthread_once_t dummy PTS_ATTRIBUTE_UNUSED = PTHREAD_ONCE_INIT;

And these two are fine as well.
Joerg Vehlow Nov. 22, 2021, 6:41 a.m. UTC | #2
Hi Cyril,

On 11/19/2021 4:23 PM, Cyril Hrubis wrote:
> Hi!
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> index e1ae59e3b..cd1aa0318 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> @@ -48,7 +48,6 @@ int main(void)
>>   	int i;
>>   	struct aiocb aiocbs[NUM_AIOCBS];
>>   	int last_req;
>> -	int err;
>>   	int ret;
>>   
>>   	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
>> @@ -85,7 +84,7 @@ int main(void)
>>   	}
>>   
>>   	for (i = 0; i < last_req - 1; i++) {
>> -		err = aio_error(&aiocbs[i]);
>> +		aio_error(&aiocbs[i]);
>>   		ret = aio_return(&aiocbs[i]);
>>   
>>   	}
> Looking at the test the whole loop here is pointless, can we remove it
> completely?
I thought the same, but I have never used aio, so I have no clue, if 
there are any side effects.
So I went for a minimal  change approach.
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> index aaf1403f9..9a0b148d9 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> @@ -51,7 +51,7 @@
>>   
>>   static void read_catalog(nl_catd cat, char *who)
>>   {
>> -	char *msg = NULL;
>> +	char *msg PTS_ATTRIBUTE_UNUSED = NULL;
>>   	int i, j;
> I guess that in this case the test is wrong as well. It does not seem
> that catgets() fails when it returns the pointer to the "not found"
> string and does not even touch errno.
Yes looks like you are right. Looks like this test can never fail.

I would fix it like this in a next revision:

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
index 46350b7f0..5c03b04ed 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
@@ -49,33 +49,22 @@
  #define MESSCAT_IN  "messcat.txt"
  #define MESSCAT_OUT "messcat.cat"

-static void read_catalog(nl_catd cat, char *who)
+static int read_catalog(nl_catd cat)
  {
+    static const char *notfound = "not found";
      char *msg PTS_ATTRIBUTE_UNUSED = NULL;
      int i, j;

-#if VERBOSE > 0
-    output("Reading the message catalog from %s...\n", who);
-#endif
-
-    errno = 0;
-
      for (i = 1; i <= 2; i++) {
          for (j = 1; j <= 2; j++) {

-            msg = catgets(cat, i, j, "not found");
-
-            if (errno != 0)
-                UNRESOLVED(errno, "catgets returned an error");
-#if VERBOSE > 1
-            output("set %i msg %i: %s\n", i, j, msg);
-#endif
+            msg = catgets(cat, i, j, notfound);
+            if (msg == notfound) {
+                return 1;
+            }
          }
      }
-
-#if VERBOSE > 0
-    output("Message catalog read successfully in %s\n", who);
-#endif
+    return 0;
  }

  static char *messcat_in =
@@ -132,7 +121,10 @@ int main(void)
      if (messcat == (nl_catd) - 1)
          UNRESOLVED(errno, "Could not open ./" MESSCAT_OUT);

-    read_catalog(messcat, "parent");
+    if (read_catalog(messcat)) {
+        printf("UNRESOLVED: Unable to read message catalog in parent");
+        return PTS_UNRESOLVED;
+    }

      child = fork();

@@ -140,8 +132,11 @@ int main(void)
          UNRESOLVED(errno, "Failed to fork");

      if (child == 0) {
-        read_catalog(messcat, "child");
-        exit(PTS_PASS);
+        if (read_catalog(messcat)) {
+            printf("FAILED: Unable to read message catalog in child");
+            return PTS_FAIL;
+        }
+        return PTS_PASS;
      }

      ctl = waitpid(child, &status, 0);


Joerg
Cyril Hrubis Nov. 22, 2021, 9:43 a.m. UTC | #3
Hi!
> > Looking at the test the whole loop here is pointless, can we remove it
> > completely?
> I thought the same, but I have never used aio, so I have no clue, if 
> there are any side effects.

As far as I can tell there is none. I guess that the original test
author was simply clueless, we used to have much more code that didn't
made any sense ten years ago and you can still occasionally find some...

> So I went for a minimal?? change approach.

Let's go for that for now then. It would be nice to fix it properly
later on.
diff mbox series

Patch

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
index e1ae59e3b..cd1aa0318 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
@@ -48,7 +48,6 @@  int main(void)
 	int i;
 	struct aiocb aiocbs[NUM_AIOCBS];
 	int last_req;
-	int err;
 	int ret;
 
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
@@ -85,7 +84,7 @@  int main(void)
 	}
 
 	for (i = 0; i < last_req - 1; i++) {
-		err = aio_error(&aiocbs[i]);
+		aio_error(&aiocbs[i]);
 		ret = aio_return(&aiocbs[i]);
 
 	}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
index 277573a38..52c8d7004 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c
@@ -48,7 +48,6 @@  int main(void)
 	int i;
 	struct aiocb aiocbs[NUM_AIOCBS];
 	int last_req;
-	int err;
 	int ret;
 
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
@@ -79,7 +78,7 @@  int main(void)
 	}
 
 	for (i = 0; i < last_req - 1; i++) {
-		err = aio_error(&aiocbs[i]);
+		aio_error(&aiocbs[i]);
 		ret = aio_return(&aiocbs[i]);
 
 	}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
index aaf1403f9..9a0b148d9 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
@@ -51,7 +51,7 @@ 
 
 static void read_catalog(nl_catd cat, char *who)
 {
-	char *msg = NULL;
+	char *msg PTS_ATTRIBUTE_UNUSED = NULL;
 	int i, j;
 
 #if VERBOSE > 0
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
index 4a60f7098..fbb7c68ff 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c
@@ -14,7 +14,7 @@ 
 #include <stdio.h>
 #include "posixtest.h"
 
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t cond PTS_ATTRIBUTE_UNUSED = PTHREAD_COND_INITIALIZER;
 
 int main(void)
 {
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
index 2fc3ff700..16c658f73 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c
@@ -92,7 +92,7 @@ 
 static int global = 0;
 static int tab[3];
 
-#define CLEANUP(n) static void clnp##n(void * arg)\
+#define CLEANUP(n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\
 {\
 	tab[global]=n; \
 	global++; \
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
index 5fa6c8b50..4437ffc77 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c
@@ -94,7 +94,7 @@  static int global = 0;
 static int tab[4];
 static pthread_key_t tld[3];
 
-#define CLEANUP(n) static void clnp##n(void * arg)\
+#define CLEANUP(n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\
 {\
 	tab[global]=n; \
 	global++; \
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
index 9ee86a5db..8a9b989f1 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c
@@ -5,7 +5,7 @@ 
  * of this license, see the COPYING file at the top level of this
  * source tree.
 
- * Test that the macro PTHREAD_MUTEX_INITIALIZER can be sued to intiailize
+ * Test that the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize
  * mutexes that are statically allocated.
  *
  */
@@ -20,7 +20,7 @@  typedef struct my_data {
 	int value;		/* Access protected by mutex */
 } my_data_t;
 
-static my_data_t data = { PTHREAD_MUTEX_INITIALIZER, 0 };
+static my_data_t data PTS_ATTRIBUTE_UNUSED = { PTHREAD_MUTEX_INITIALIZER, 0 };
 
 int main(void)
 {
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
index a7099688b..d3c0bdae9 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c
@@ -32,9 +32,7 @@  static void *f1(void *parm);
 static int ret;			/* Save return value of
 				   pthread_mutex_timedlock(). */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
-static time_t currsec1, currsec2;	/* Variables for saving time before
-				   and afer locking the mutex using
-				   pthread_mutex_timedlock(). */
+
 /****************************
  *
  * MAIN()
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
index 077bfe76d..f51106bdf 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c
@@ -40,9 +40,7 @@  static void *f1(void *parm);
 static int ret;			/* Save return value of
 				   pthread_mutex_timedlock(). */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
-static time_t currsec1, currsec2;	/* Variables for saving time before
-				   and afer locking the mutex using
-				   pthread_mutex_timedlock(). */
+
 /****************************
  *
  * MAIN()
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
index 0eda6e58f..afca84eed 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c
@@ -40,9 +40,7 @@  static void *f1(void *parm);
 static int ret;			/* Save return value of
 				   pthread_mutex_timedlock(). */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
-static time_t currsec1, currsec2;	/* Variables for saving time before
-				   and afer locking the mutex using
-				   pthread_mutex_timedlock(). */
+
 /****************************
  *
  * MAIN()
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
index baf429503..a5f8b3383 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c
@@ -36,9 +36,7 @@  static void *f1(void *parm);
 static int ret;			/* Save return value of
 				   pthread_mutex_timedlock(). */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;	/* The mutex */
-static time_t currsec1, currsec2;	/* Variables for saving time before
-				   and afer locking the mutex using
-				   pthread_mutex_timedlock(). */
+
 /****************************
  *
  * MAIN()
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
index e7e86bfa8..2145bde8a 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c
@@ -103,7 +103,6 @@  static struct _scenar {
 #define NSCENAR (sizeof(scenarii)/sizeof(scenarii[0]))
 
 static char do_it = 1;
-static char woken = 0;
 static unsigned long count_ope = 0;
 #ifdef WITH_SYNCHRO
 static sem_t semsig1;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
index 27f0ee3d7..39dacb73e 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c
@@ -39,13 +39,13 @@  static int value;			/* value protected by mutex */
 
 int main(void)
 {
-	int i, rc;
+	int i;
 	pthread_t threads[THREAD_NUM];
 
 	/* Create threads */
 	fprintf(stderr, "Creating %d threads\n", THREAD_NUM);
 	for (i = 0; i < THREAD_NUM; ++i)
-		rc = pthread_create(&threads[i], NULL, func, NULL);
+		pthread_create(&threads[i], NULL, func, NULL);
 
 	/* Wait to join all threads */
 	for (i = 0; i < THREAD_NUM; ++i)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
index 909b53bf4..8e8617bbd 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c
@@ -37,8 +37,6 @@ 
 #include <stdio.h>
 #include "posixtest.h"
 
-static pthread_mutex_t new_mutex;	/* The mutex. */
-
 int main(void)
 {
 	pthread_mutexattr_t mta;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
index 6e519962b..d3392f908 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c
@@ -11,5 +11,6 @@ 
    */
 
 #include <pthread.h>
+#include "posixtest.h"
 
-static pthread_once_t dummy = PTHREAD_ONCE_INIT;
+static pthread_once_t dummy PTS_ATTRIBUTE_UNUSED = PTHREAD_ONCE_INIT;