Message ID | 20240416142458.3353383-1-denkenz@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2,1/4] util: Remove confusing static keyword use | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
prestwoj/iwd-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-ci-build | success | Build - Configure |
prestwoj/iwd-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-ci-clang | success | clang PASS |
prestwoj/iwd-ci-makecheck | success | Make Check |
prestwoj/iwd-ci-testrunner | success | test-runner PASS |
On 4/16/24 09:24, Denis Kenzior wrote: > '__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(-) > Applied.
diff --git a/ell/util.h b/ell/util.h index 80b29b7bb6e3..237ea4824b06 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; \ + const size_t __n = L_ARRAY_SIZE(__elems); \ bool __r = false; \ for (__i = 0; __i < __n && !__r; __i++) \ __r = (cmp); \