diff mbox series

[1/4] util: Remove confusing static keyword use

Message ID 20240415191454.3259243-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/4] util: Remove confusing static keyword use | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-setupell fail Setup ELL - make FAIL: The command rsautl was deprecated in version 3.0. Use 'pkeyutl' instead. The command rsautl was deprecated in version 3.0. Use 'pkeyutl' instead. writing RSA key writing RSA key writing RSA key writing RSA key writing RSA key In file included from ./ell/ell.h:8, from unit/test-util.c:17: unit/test-util.c: In function ‘test_set_bit’: ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:203:9: note: in expansion of macro ‘L_BIT_SET’ 203 | L_BIT_SET(&bitmap[0], 0); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:204:9: note: in expansion of macro ‘L_BIT_SET’ 204 | L_BIT_SET(bitmap, 1); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:205:9: note: in expansion of macro ‘L_BIT_SET’ 205 | L_BIT_SET(bitmap, 2); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:206:9: note: in expansion of macro ‘L_BIT_SET’ 206 | L_BIT_SET(bitmap, 3); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:211:9: note: in expansion of macro ‘L_BIT_SET’ 211 | L_BIT_SET(bitmap, 63); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:212:9: note: in expansion of macro ‘L_BIT_SET’ 212 | L_BIT_SET(bitmap, 62); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:213:9: note: in expansion of macro ‘L_BIT_SET’ 213 | L_BIT_SET(bitmap, 61); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:214:9: note: in expansion of macro ‘L_BIT_SET’ 214 | L_BIT_SET(bitmap, 60); | ^~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:379:39: note: in expansion of macro ‘_L_BIT_TO_MASK’ 379 | _L_BIT_TO_OFFSET(bits, nr) |= _L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:219:9: note: in expansion of macro ‘L_BIT_SET’ 219 | L_BIT_SET(&one, 0); | ^~~~~~~~~ unit/test-util.c: In function ‘test_clear_bit’: ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:382:40: note: in expansion of macro ‘_L_BIT_TO_MASK’ 382 | _L_BIT_TO_OFFSET(bits, nr) &= ~_L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:227:9: note: in expansion of macro ‘L_BIT_CLEAR’ 227 | L_BIT_CLEAR(&bitmap[0], 3); | ^~~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:382:40: note: in expansion of macro ‘_L_BIT_TO_MASK’ 382 | _L_BIT_TO_OFFSET(bits, nr) &= ~_L_BIT_TO_MASK(bits, nr) | ^~~~~~~~~~~~~~ unit/test-util.c:228:9: note: in expansion of macro ‘L_BIT_CLEAR’ 228 | L_BIT_CLEAR(bitmap, 63); | ^~~~~~~~~~~ In file included from unit/test-util.c:12: unit/test-util.c: In function ‘test_is_bit_set’: ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:239:16: note: in expansion of macro ‘L_BIT_TEST’ 239 | assert(L_BIT_TEST(&bitmap[0], 0) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:239:16: note: in expansion of macro ‘L_BIT_TEST’ 239 | assert(L_BIT_TEST(&bitmap[0], 0) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:240:16: note: in expansion of macro ‘L_BIT_TEST’ 240 | assert(L_BIT_TEST(bitmap, 1) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:240:16: note: in expansion of macro ‘L_BIT_TEST’ 240 | assert(L_BIT_TEST(bitmap, 1) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:241:16: note: in expansion of macro ‘L_BIT_TEST’ 241 | assert(L_BIT_TEST(bitmap, 2) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:241:16: note: in expansion of macro ‘L_BIT_TEST’ 241 | assert(L_BIT_TEST(bitmap, 2) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:242:16: note: in expansion of macro ‘L_BIT_TEST’ 242 | assert(L_BIT_TEST(bitmap, 3) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:242:16: note: in expansion of macro ‘L_BIT_TEST’ 242 | assert(L_BIT_TEST(bitmap, 3) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:243:16: note: in expansion of macro ‘L_BIT_TEST’ 243 | assert(L_BIT_TEST(bitmap, 4) == false); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:243:16: note: in expansion of macro ‘L_BIT_TEST’ 243 | assert(L_BIT_TEST(bitmap, 4) == false); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:245:16: note: in expansion of macro ‘L_BIT_TEST’ 245 | assert(L_BIT_TEST(bitmap, 63) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:245:16: note: in expansion of macro ‘L_BIT_TEST’ 245 | assert(L_BIT_TEST(bitmap, 63) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:246:16: note: in expansion of macro ‘L_BIT_TEST’ 246 | assert(L_BIT_TEST(bitmap, 55) == false); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:246:16: note: in expansion of macro ‘L_BIT_TEST’ 246 | assert(L_BIT_TEST(bitmap, 55) == false); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:248:16: note: in expansion of macro ‘L_BIT_TEST’ 248 | assert(L_BIT_TEST(&one, 0) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:248:16: note: in expansion of macro ‘L_BIT_TEST’ 248 | assert(L_BIT_TEST(&one, 0) == true); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:249:16: note: in expansion of macro ‘L_BIT_TEST’ 249 | assert(L_BIT_TEST(&one, 1) == false); | ^~~~~~~~~~ ./ell/util.h:371:31: error: variable ‘mask’ set but not used [-Werror=unused-but-set-variable] 371 | const typeof(*(bits)) mask = (typeof(*(bits)))1 << shift; \ | ^~~~ ./ell/util.h:385:41: note: in expansion of macro ‘_L_BIT_TO_MASK’ 385 | ((~_L_BIT_TO_OFFSET(bits, nr) & _L_BIT_TO_MASK(bits, nr)) == 0) | ^~~~~~~~~~~~~~ unit/test-util.c:249:16: note: in expansion of macro ‘L_BIT_TEST’ 249 | assert(L_BIT_TEST(&one, 1) == false); | ^~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2009: unit/test-util.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1295: all] Error 2
prestwoj/iwd-ci-makedistcheck pending makedistcheck SKIP
prestwoj/iwd-ci-build pending build SKIP
prestwoj/iwd-ci-incremental_build pending incremental_build SKIP
prestwoj/iwd-ci-makecheckvalgrind pending makecheckvalgrind SKIP
prestwoj/iwd-ci-clang pending clang SKIP
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-testrunner pending testrunner SKIP

Commit Message

Denis Kenzior April 15, 2024, 7:14 p.m. UTC
'__n' is declared as static const which is confusing since it
would imply that __n is only initialized once.  This works out in the
end since the macro used in a separate anonymous block, but some compilers
(i.e. clang) will generate a symbol table entry for '__n'.  This is not
needed since the expression is always constant.

Declare '__n' as a const size_t instead since that is the type produced
by the sizeof() operation used by L_ARRAY_SIZE.

While here, also declare '__i' as size_t to match '__n'.

Fixes: 4a9f6388dd7f ("util: Add L_IN_SET macros")
---
 ell/util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/ell/util.h b/ell/util.h
index 80b29b7bb6e3..b5d96754e8ae 100644
--- a/ell/util.h
+++ b/ell/util.h
@@ -349,8 +349,8 @@  inline __attribute__((always_inline)) void _l_close_cleanup(void *p)
 #define _L_IN_SET_CMP(val, type, cmp, ...) __extension__ ({		\
 		const type __v = (val);					\
 		const typeof(__v) __elems[] = {__VA_ARGS__};		\
-		unsigned int __i;					\
-		static const unsigned int __n = L_ARRAY_SIZE(__elems);	\
+		size_t __i;						\
+		size_t __n = L_ARRAY_SIZE(__elems);			\
 		bool __r = false;					\
 		for (__i = 0; __i < __n && !__r; __i++)			\
 			__r = (cmp);					\