[En-Nut-Discussion] Compiler errors on signed/unsigned compares

Michel Hendriks michel at stream-it.nl
Mon Nov 7 17:13:31 CET 2005


Hi all,

 

I have found a few problems concerning signed/unsigned compares in a few
NutOs sources.

Using WinAVR-20030424, it complains about pro\dhcpc.c, pro\wins.c and
fs\pnutfs.c 

 

pro\dhcpc.c (function DhcpRecvMessage , line 1025):

        if (rc > (sizeof(struct bootp) - sizeof(bp->bp_options) + 5)) {

this must be changed to:

        if (rc > (int) (sizeof(struct bootp) - sizeof(bp->bp_options) + 5))
{

 

pro\wins.c (function NutWinsNameQuery , line 94):

    int i, j; 

these must be declared as:

    u_int i, j;

 

fs\pnutfs.c (function PnutFileWrite, line 1113):

        if (blksiz >= len) {

this must be changed to:

        if ((int) blksiz >= len) {

 

Now the funny/scary thing: Using WinAVR-20030913 the gcc compiler no longer
complains about this!

This is scary as I think the older compiler is rightfully complaining about
these compares.

 

Is there a compiler option we can use to enable the signed/unsigned checks? 

Or is the newer compiler so smart that it can work out these compares by
itself?

Or am I just too picky :-) ?

 

Greetings,

Michel




More information about the En-Nut-Discussion mailing list