buglwIP - A Lightweight TCP/IP stack - Bugs: bug #27521, Data type warning in api_msg.c

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #27521: Data type warning in api_msg.c

Submitter:  Eric Tron <friendfish>
Submitted:  Fri 25 Sep 2009 01:24:36 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Compiler Warning Status:  Wont Fix
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.3.1

Fri 25 Sep 2009 11:48:09 AM UTC, comment #2: 

You could wrap that in:

#if (size_t) 0x10000 != 0
if....
#endif

Bill Auerbach <billauerbach>
Fri 25 Sep 2009 08:01:58 AM UTC, comment #1: 

The code looks OK to me, but you're right that if size_t is a u16_t then the check is unnecessary and the compiler will generate a warning.  I would just ignore the warning as we know it's OK.  The code needs to be like that because it won't always be false on other platforms (where size_t > u16_t).


Kieran Mansley <kieranm>
Group Member
Fri 25 Sep 2009 01:24:36 AM UTC, original submission:  

Hi,
In my compiler there always a warning appeared that is :
"Condition is always false".
The related source code is located in "api_msg.c" the "do_writemore" function and that is:
"diff = conn->write_msg->msg.w.len - conn->write_offset;
if(diff>0xffffUL)"(in 1.3.1 version);

"if((conn->write_msg->msg.w.len - conn->write_offset > 0xffff))"(in 1.3.0).

the reason is obviously, the result is never larger than 0xffff, in 1.3.0 "msg.w.len" is defined as "u16_t" and "write_offset" is defined "u16_t" as well. However in 1.3.1 both them are defined as "size_t", in some 16-bit cpu the "size_t" is "unsgined int" is also 16bit data, so the condition is always false.

Now, I want dismiss the compiler warning, so I change the data type to "u32_t", anyway, is that right? Would you give some proposal?

Eric Tron <friendfish>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by billauerbach (Posted a comment)
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by friendfish (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-09-25 kieranm StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code