Wireshark-dev: Re: [Wireshark-dev] ARM Build
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Thu, 16 Oct 2014 15:07:32 -0700
On Oct 15, 2014, at 11:43 AM, Guy Harris <guy@xxxxxxxxxxxx> wrote:

>> I have try to build lasted trunk/master of wireshark (to test speed..)
>> but don't build :
>> 
>> ftype-pcre.c: In function 'raw_flag_needed':
>> ftype-pcre.c:64:13: error: comparison is always true due to limited
>> range of data type [-Werror=type
>> -limits]
>>            (s[i] >= '\xFA' && s[i] <= '\xFF'))
>>            ^
> 
> We should probably make "s" a "const guchar *", and do the appropriate cast.

The warning was due to unsigned 8-bit values always being <= 0xFF.

A better fix is to extract the upper and lower nibbles and to make sure they're both >= 0xA, as a nibble is always <= 0xF (fewer tests, no special-casing of 0xFF).  I checked that in, with the nibble extractions casting the result to guchar to make sure no sign-extension is done on platforms with *signed* characters.

Checked into the trunk and backported to 1.12 and 1.10.

>> cc1: all warnings being treated as errors
>> ./wslua_internals.c: In function 'wslua_hex2bin':
>> ./wslua_internals.c:556:9: error: comparison is always false due to
>> limited range of data type [-Wer
>> ror=type-limits]
>>        if (c < 0) {
>>        ^
>> ./wslua_internals.c:565:9: error: comparison is always false due to
>> limited range of data type [-Wer
>> ror=type-limits]
>>        if (d < 0) break;
>>        ^
> 
> "static const char str_to_nibble[]" should be "static const gint8 str_to_nibble[]", and "char c, d" should be "gint8 c, d" (the underlying data type would be "signed char", but they're 8-bit signed integers, not characters, so "gint8" is clearer).
> 
>> strutil.c: In function 'hex_str_to_bytes_encoding':
>> strutil.c:634:13: error: comparison is always false due to limited
>> range of data type [-Werror=type-
>> limits]
>>            if (c < 0) {
>>            ^
>> strutil.c:641:13: error: comparison is always false due to limited
>> range of data type [-Werror=type-
>> limits]
>>            if (d < 0) {
>>            ^
> 
>> strutil.c:650:13: error: comparison is always true due to limited
>> range of data type [-Werror=type-l
>> imits]
>>            if (sep > 0 && *end == sep && str_to_nibble[(int)*(end+1)] > -1) {
>>            ^
> 
> ...and the same applies there.

...and, in addition, the gchars used as array subscripts should be cast to guchar, so that they're not sign-extended.

Checked into the trunk and backported to 1.12 (1.10 doesn't have that code).

>> airpcap_loader.c: In function 'airpcap_if_get_device_supported_channels_array':
>> airpcap_loader.c:841:17: error: case label value is less than minimum
>> value for type [-Werror]
>>                case -1:
>>                ^
>> airpcap_loader.c:870:17: error: case label value is less than minimum
>> value for type [-Werror]
>>                case -1:
>>                ^
> 
> Change ExtChannel in struct _AirpcapChannelInfo in caputils/airpcap.h from gchar to gint8.

Checked into the trunk and backported to 1.12 and 1.10.