Wireshark-dev: Re: [Wireshark-dev] buildbot failure in Wireshark (development) on OSX

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Fri, 14 Jan 2011 09:26:29 -0500
Graham Bloice wrote:
Any idea why the OSX compilers are complaining about this code in packet-dnp.c:

 if (!header_only || al_objq_index > 0) {
    start_offset = offset;
    for (item_num = 0; item_num < num_items; item_num++)
    {
      /* Create Point item and Process Index */
if (AL_OBJQL_IDX_NI <= al_objq_index && al_objq_index <= AL_OBJQL_IDX_4O) <---------- Error here

[...]

The reported error is:

packet-dnp.c: In function 'dnp3_al_process_object':
packet-dnp.c:1566: warning: comparison is always true due to limited range of data type

The variable (al_objq_index) is three bits so has a value between 0 and 7 and the constants are enumerations of the values. AL_OBJQL_IDX_NI is 0 and AL_OBJQL_IDX_4O is 3. I suspect that the following if() might also error out as it just checks for a different range of values (4-6).

The problem is that al_objq_index is a guint8 and AL_OBJQL_IDX_NI is 0x0. Since an unsigned variable can't go negative, al_objq_index is ALWAYS greater than AL_OBJQL_IDX_NI (0).

From quickly looking at the code, I'd guess that this comparison can simply be removed.