buglwIP - A Lightweight TCP/IP stack - Bugs: bug #26523, Compiler Warnings

 
 

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

bug #26523: Compiler Warnings

Submitted by:  Rikke Ottesen <ro03>
Submitted on:  Mon 11 May 2009 08:39:15 AM UTC  
 
Category:  None Severity:  2 - Minor
Item Group:  Compiler Warning Status:  Fixed
Privacy:  Public Assigned to:  Simon Goldschmidt <goldsimon>
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.3.0

( Jump to the original submission)

Sun 24 Jan 2010 02:52:15 PM UTC, comment #12: 

I'm now not getting any more warnings (aside from httpd.h) throughout the code (both with the win32 and unix port - aside from the missing casts mentioned in bug #28659) so please report back anything that I might have overlooked.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sat 23 Jan 2010 06:10:44 PM UTC, comment #11: 

I hope to have fixed all compiler warnings (aside from 'conditional expression is constant' caused by while(0)/while(1) in macros) in all the code except for snmp and ppp.

Please test and report back if I haven't.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Wed 13 May 2009 01:43:29 PM UTC, comment #10: 

The problem is, standard C forces upcasting in some cases (most notably the >> and << operators) and you're going to get a downsize warning that you didn't even create in your code.  Few if any compilers turn this warning on by default for the reason we see: causing many downsize warnings that really have no effect.  Anding and shifting bytes for endian swaps will cause warnings without casting the result of the and to a u8_t.  If the warnings are a problem, I find it falls out pretty quickly in testing.

Bill Auerbach <billauerbach>
Wed 13 May 2009 09:06:30 AM UTC, comment #9: 

I totally agree with you on the downsizing, so you know the writer have though about this and it does not cause any problems!

The reason why I added the bug was to let you know these.

Right now my warning level is set to giving me an error on those, but I'll just disregard those for now. NP!

Rikke Ottesen <ro03>
Wed 13 May 2009 08:58:54 AM UTC, comment #8: 

I would favour explicit casts when downsizing from a u16 to a u8 for example, but the reverse should not need a cast.  I prefer it this way as it shows the writer of the code has (maybe) thought about the implication of the change in size, and thinks it is OK.  Without the explicit cast it could just be something they overlooked, so the compiler is right to warn.  Similarly for changes between signed and unsigned variables. 

This should be regarded as pretty low priority though, and maybe just a guide for writing or modifying code in the future.

Rikke: are the warnings causing any problems?  I prefer to get rid of warnings, but just want to check that there isn't a more serious issue?

Kieran Mansley <kieranm>
Project Member
Wed 13 May 2009 08:58:04 AM UTC, comment #7: 

Ok ;)
I'll wait for the new release and hope for lesser warnings.

As you said it is a question whether you have to change it, but it just looks so nice, when you compile and there are zero warnings :D

I'll leave it here.

Thanks!
Rikke

Rikke Ottesen <ro03>
Wed 13 May 2009 08:48:58 AM UTC, comment #6: 

> Do you think the changes in 1.3.1 can have any effect on this matter?


Since it is not released yet, we can make them to :-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Wed 13 May 2009 08:46:57 AM UTC, comment #5: 

I use the ARM/Thumb C/C++ Compiler, RVCT3.0 [Build 617] under 32 bit.

Do you think the changes in 1.3.1 can have any effect on this matter?

Rikke Ottesen <ro03>
Wed 13 May 2009 08:17:15 AM UTC, comment #4: 

From the error message, I guess you are compiling on MS-VS under 32-bit, then? That would be strange since I don't see the warnings with the VS-projects in contrib.

> How do I get the newest version of lwIP?
> Is the newest version not 1.3.0?


It is the newest released version. However, it's been a year since that and there have been a lot of changes in CVS since then. v1.3.1 will be released in the next weeks or months...

> Could you not just cast the value x or y to remove the warnings,
> if you are sure that this does not cause any problems?


The question is whether we have to. In my opinion, this tends to make the code less readable, so unless we have to, I'd prefer not to insert the casts. Anyway, I thought these cast warnings are only valid for C++ (not for C)? Or was that only for pointer casts?

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Wed 13 May 2009 08:04:13 AM UTC, comment #3: 

I'm not compiling for 64 bit OS.

How do I get the newest version of lwIP?
Is the newest version not 1.3.0?

Could you not just cast the value x or y to remove the warnings, if you are sure that this does not cause any problems?

Rikke Ottesen <ro03>
Wed 13 May 2009 06:03:55 AM UTC, comment #2: 

I had a quick look over some of the lines mentioned, and I think at least most of these are not solved by patch #6521.

Most of the warnings seem to be something like:
u8_t x;
u16_t y;
x = y; or y = x; << warning here: x and y have different sizes.

Do we really care for that warning? The implicit conversion done by the compiler is what we want, I guess...

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 11 May 2009 02:54:18 PM UTC, comment #1: 

Is this compiling on a 64 bit OS?  There's a task that should have improved things in that case:

https://savannah.nongnu.org/patch/?6521

If you feel able to try CVS head and report if there's still an issue, that would be very helpful.

Kieran Mansley <kieranm>
Project Member
Mon 11 May 2009 08:39:15 AM UTC, original submission:  

I see these warnings when I compile.

1.3.0/core/dhcp.c(276) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(658) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(735) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(787) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(932) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(984) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/dhcp.c(1031) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/tcp_in.c(113) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_in.c(155) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/tcp_out.c(290) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(295) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(298) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(382) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(460) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(463) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(539) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(707) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(710) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(831) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(834) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(914) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/tcp_out.c(917) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/dns.c(612) : warning C4244: '=' : conversion from 'unsigned short ' to 'unsigned char ', possible loss of data
1.3.0/core/dns.c(622) : warning C4244: '=' : conversion from 'unsigned short ' to 'unsigned char ', possible loss of data
1.3.0/core/dns.c(623) : warning C4244: '=' : conversion from 'unsigned short ' to 'unsigned char ', possible loss of data
1.3.0/core/dns.c(451) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/ipv4/icmp.c(161) : warning C4244: 'function' : conversion from 'long ' to 'unsigned short ', possible loss of data
1.3.0/core/ipv4/icmp.c(170) : warning C4244: 'function' : conversion from 'long ' to 'unsigned short ', possible loss of data
1.3.0/core/ipv4/icmp.c(242) : warning C4244: 'function' : conversion from 'long ' to 'unsigned short ', possible loss of data
1.3.0/core/ipv4/icmp.c(294) : warning C4244: 'function' : conversion from 'long ' to 'unsigned short ', possible loss of data
1.3.0/core/ipv4/icmp.c(84) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(139) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(161) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(170) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(242) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(243) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(294) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/icmp.c(295) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/ipv4/ip.c(496) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/ip.c(497) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/ip.c(501) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/ipv4/ip_frag.c(731) : warning C4761: integral size mismatch in argument; conversion supplied
1.3.0/core/ipv4/ip_frag.c(737) : warning C4761: integral size mismatch in argument; conversion supplied

1.3.0/core/ipv4/inet_chksum.c(169) : warning C4244: 'return' : conversion from 'unsigned long ' to 'unsigned short ', possible loss of data

Is this consider being fixed in a newer version?

Rikke Ottesen <ro03>

 

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 goldsimon (Posted a comment)
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by ro03 (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-24 goldsimon StatusIn Progress => Fixed
        Open/ClosedOpen => Closed
    2010-01-23 goldsimon StatusNone => In Progress
        Assigned toNone => goldsimon
    2009-05-13 kieranm Severity3 - Normal => 2 - Minor

    Back to the top


    Powered by Savane 3.5