[Olsr-dev] char default signed/unsigned

John Hay (spam-protected)
Tue Sep 25 09:18:49 CEST 2007


Hi,

I'm trying to compile olsr on FreeBSD/arm and saw these warnings:

#######################################
gcc -Wall -Wextra -Wold-style-definition -Wdeclaration-after-statement -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wsign-compare -Waggregate-return -Wmissing-noreturn -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wnested-externs -Winline -Wdisabled-optimization -O2 -g  -Isrc -I./src -pthread -DSUPPORT_OLD_PLUGIN_VERSIONS=1 -DOLSRD_GLOBAL_CONF_FILE=\"/usr/local/etc/olsrd.conf\"    -c -o src/lq_avl.o src/lq_avl.c
src/lq_avl.c: In function 'avl_rotate_right':
src/lq_avl.c:179: warning: comparison is always false due to limited range of data type
src/lq_avl.c: In function 'avl_rotate_left':
src/lq_avl.c:212: warning: comparison is always false due to limited range of data type
src/lq_avl.c: In function 'post_insert':
src/lq_avl.c:229: warning: comparison is always false due to limited range of data type
src/lq_avl.c:235: warning: comparison is always false due to limited range of data type
src/lq_avl.c: In function 'avl_insert':
src/lq_avl.c:375: warning: comparison is always false due to limited range of data type
src/lq_avl.c: In function 'avl_post_delete':
src/lq_avl.c:452: warning: comparison is always false due to limited range of data type
src/lq_avl.c:461: warning: comparison is always false due to limited range of data type
src/lq_avl.c: In function 'avl_delete_worker':
src/lq_avl.c:543: warning: comparison is always false due to limited range of data type
src/lq_avl.c:558: warning: comparison is always false due to limited range of data type
#######################################

It seems to be because inside struct avl_node, balance is of type char,
but the C standards leave it up to implementation if a char is signed
ot not. It looks like on FreeBSD/arm a char is unsigned. If you want to
make sure a char is signed, you should add "signed" in front of it.

Here are a few links that all say that the signed/unsigned-ness of type
char is implementation specific:
http://www.trilithium.com/johan/2005/01/char-types/
http://home.att.net/~jackklein/c/inttypes.html
http://www.ibm.com/developerworks/power/library/pa-ctypes1/index.html?ca=dgr-lnxwCTypesP2

John
-- 
John Hay -- (spam-protected) / (spam-protected)




More information about the Olsr-dev mailing list