On Die, 2007-09-25 at 09:18 +0200, John Hay wrote:
> Hi,
> 
> I'm trying to compile olsr on FreeBSD/arm and saw these warnings:

Thanks for reporting this.

> #######################################
> 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
[...]
> #######################################
> 
> 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.

ACK, that should be changed: if it's used as a small integer, it must be
explicitly "signed" or "unsigned" (or one of the "olsr_*8_t" types).
Hannes: "unsigned char" or "signed char"?
>From above I would guess "signed" (otherwise the comparisons wouldn't
make sense).

Do we have more of these hidden somewhere (there is one in the Windows
p[oa]rt I know of but I expect all compilers - including gcc - in the
monopolists world to default to the same no one will notice it like
above)?

> Here are a few links that all say that the signed/unsigned-ness of type
> char is implementation specific:

"char" a such has no signedness and it is a different type type than
"signed char" and "unsigned char". It's actually the
conversion/promotion from "char" to "signed char" or "unsigned char" if
one uses the value as a small integer (e.g. if you use it in
calculations).

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




