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

Submitted by:  Eric Tron <friendfish>
Submitted on:  Fri 25 Sep 2009 01:24:36 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Compiler WarningStatus: Wont Fix
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned 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>
Project Administrator
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>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 25 Sep 2009 08:01:58 AM UTCkieranmStatusNone=>Wont Fix
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1