Hi,
while fixing some trivial compiler warnings in openbsc I stumbled over
this:
Making all in abis
CC abis_test.o
abis_test.c: In function ‘test_simple_sw_config’:
abis_test.c:68:9: warning: format ‘%u’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘long int’ [-Wformat=]
printf("Start: %u len: %zu\n", descr[0].start - simple_config,
descr[0].len);
^
abis_test.c: In function ‘test_dual_sw_config’:
abis_test.c:111:9: warning: format ‘%u’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘long int’ [-Wformat=]
printf("Start: %u len: %zu\n", descr[0].start - dual_config, descr[0].len);
^
abis_test.c:115:9: warning: format ‘%u’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘long int’ [-Wformat=]
printf("Start: %u len: %zu\n", descr[1].start - dual_config, descr[1].len);
^
abis_test.c: In function ‘test_sw_selection’:
abis_test.c:132:9: warning: format ‘%u’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘long int’ [-Wformat=]
printf("Start: %u len: %zu\n", descr[0].start - load_config, descr[0].len);
^
abis_test.c:136:9: warning: format ‘%u’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘long int’ [-Wformat=]
printf("Start: %u len: %zu\n", descr[1].start - load_config, descr[1].len);
The relevant expression is:
descr[1].start - load_config
and variations thereof.
descr[1].start is declared include/openbsc/abis_nm.h as:
const uint8_t *start;
simple_config is declared as:
static const uint8_t simple_config[]
So an address is taken and the first element (implicitly) of an uint8
array is substracted from it.
Maybe I just don't get the beauty of this, for me this looks wrong.
Kind regards,
-Alex