[Dovecot] Pigeonhole 2.2 build issue on arm
When building Pigeonhole 2.2 for ARM, the following warnings are produced:
uri-mailto.c: In function '_parse_hex_value': uri-mailto.c:139: warning: comparison is always false due to limited range of data type uri-mailto.c:145: warning: comparison is always false due to limited range of data type
The problem is a test assuming that char is a signed type :
static inline int _decode_hex_digit(char digit) { ...
static bool _parse_hex_value(const char **in, char *out) { char value; // <<--- change to "int".
if ( **in == '\0' || (value=_decode_hex_digit(**in)) < 0 )
return FALSE;
*out = value << 4;
(*in)++;
if ( **in == '\0' || (value=_decode_hex_digit(**in)) < 0 )
return FALSE;
This is untested, but I changed the "char value" to "int value" to correct the signed comparisons. There are no warnings when building for x86 in either case, btw.
Also, the two tests for "**in == '\0'" seem to be unnecessary?
[/share/Public/XDove/dovecot-2.0-pigeonhole-0.2.2/src] # gcc -v Using built-in specs. Target: arm-none-linux-gnueabi Configured with: ../gcc-4.2/configure --build=i386-pc-linux-gnu --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi --prefix=/opt --disable-nls --disable-static --with-as=/home/slug/optware/cs08q1armel/toolchain/arm-2008q1/bin/arm-none-linux-gnueabi-as --with-ld=/home/slug/optware/cs08q1armel/toolchain/arm-2008q1/bin/arm-none-linux-gnueabi-ld --enable-languages=c,c++ --disable-multilib --enable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --enable-shared --enable-symvers=gnu --enable-__cxa_atexit Thread model: posix gcc version 4.2.3 [/share/Public/XDove/dovecot-2.0-pigeonhole-0.2.2/src] # make ... libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../../../.. -I./.. -I./../../.. -I/share/Public/XDove/dovecot-2.0.9 -I/share/Public/XDove/dovecot-2.0.9/src/lib -I/share/Public/XDove/dovecot-2.0.9/src/lib-dict -I/share/Public/XDove/dovecot-2.0.9/src/lib-mail -I/share/Public/XDove/dovecot-2.0.9/src/lib-imap -I/share/Public/XDove/dovecot-2.0.9/src/lib-charset -I/share/Public/XDove/dovecot-2.0.9/src/lib-index -I/share/Public/XDove/dovecot-2.0.9/src/lib-storage -I/share/Public/XDove/dovecot-2.0.9/src/lib-storage/index -I/share/Public/XDove/dovecot-2.0.9/src/lib-storage/index/raw -std=gnu99 -g -O2 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast -Wstrict-aliasing=2 -MT ntfy-mailto.lo -MD -MP -MF .deps/ntfy-mailto.Tpo -c ntfy-mailto.c -fPIC -DPIC -o .libs/ntfy-mailto.o uri-mailto.c: In function '_parse_hex_value': uri-mailto.c:139: warning: comparison is always false due to limited range of data type uri-mailto.c:145: warning: comparison is always false due to limited range of data type
When building Pigeonhole 2.2 for ARM, the following warnings are produced:
uri-mailto.c: In function '_parse_hex_value': uri-mailto.c:139: warning: comparison is always false due to limited range of data type uri-mailto.c:145: warning: comparison is always false due to limited range of data type
The problem is a test assuming that char is a signed type :
Indeed. This is what I would call a programming atrocity. Notice the return type casts in the _decode_hex_digit function; no idea why the actual return type was char.
This is untested, but I changed the "char value" to "int value" to correct the signed comparisons. There are no warnings when building for x86 in either case, btw.
That is a good fix. I did it a little more elaborate though:
http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/8a07ae3e0a2e
Also, the two tests for "**in == '\0'" seem to be unnecessary?
Yes, that too.
Regards,
Stephan.
participants (2)
-
Stephan Bosch
-
Tom Talpey