Wireshark mailing list archives

Re: buildbot failure in Wireshark (development) on OSX


From: Graham Bloice <graham.bloice () trihedral com>
Date: Fri, 14 Jan 2011 14:30:22 +0000

On 14/01/2011 14:26, Jeff Morriss wrote:
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.

Thanks.  I'll fix it up.

-- 
Regards,

Graham Bloice

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: