Skip to content

Commit 916928a

Browse files
thugheskartben
authored andcommitted
tests: posix: Annotate unused variables with __unused
Instead of disabling the -Wunused-variable warning for the entire file, we can explicitly mark the variables that are unused with __unused. Signed-off-by: Tom Hughes <[email protected]>
1 parent 5a57c3b commit 916928a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/posix/headers/src/pthread_h.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <zephyr/posix/pthread.h>
1313
#endif
1414

15-
#pragma GCC diagnostic push
16-
#pragma GCC diagnostic ignored "-Wunused-variable"
1715
/**
1816
* @brief existence test for `<pthread.h>`
1917
*
@@ -45,7 +43,7 @@ ZTEST(posix_headers, test_pthread_h)
4543
/* zassert_not_equal(-1, PTHREAD_MUTEX_ROBUST); */ /* not implemented */
4644
/* zassert_not_equal(-1, PTHREAD_MUTEX_STALLED); */ /* not implemented */
4745

48-
pthread_once_t once = PTHREAD_ONCE_INIT;
46+
__unused pthread_once_t once = PTHREAD_ONCE_INIT;
4947

5048
/* zassert_not_equal(-1, PTHREAD_PRIO_INHERIT); */ /* not implemented */
5149
zassert_not_equal(-1, PTHREAD_PRIO_NONE);
@@ -57,8 +55,8 @@ ZTEST(posix_headers, test_pthread_h)
5755
zassert_not_equal(-1, PTHREAD_SCOPE_PROCESS);
5856
zassert_not_equal(-1, PTHREAD_SCOPE_SYSTEM);
5957

60-
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
61-
pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
58+
__unused pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
59+
__unused pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
6260
/* pthread_rwlock_t lock = POSIX_READER_WRITER_LOCKS_INITIALIZER; */ /* not implemented */
6361

6462
zassert_not_null(pthread_atfork);
@@ -161,4 +159,3 @@ ZTEST(posix_headers, test_pthread_h)
161159
zassert_not_null(pthread_testcancel);
162160
#endif
163161
}
164-
#pragma GCC diagnostic pop

0 commit comments

Comments
 (0)