buglwIP - A Lightweight TCP/IP stack - Bugs: bug #43235, Numerous compiler warnings in...

 
 

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

bug #43235: Numerous compiler warnings in ppp_new code

Submitted by:  Simon Goldschmidt <goldsimon>
Submitted on:  Tue 16 Sep 2014 06:39:35 PM UTC  
 
Category:  PPP Severity:  1 - Wish
Item Group:  Compiler Warning Status:  Fixed
Privacy:  Public Assigned to:  Simon Goldschmidt <goldsimon>
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

( Jump to the original submission)

Sun 22 Feb 2015 09:10:38 PM UTC, comment #11: 

> I don't think a missing cast qualify as "really wrong"


In fact, a really expensive compiler just told me that this missing cast (unsigned to signed) could be unportable on some compilers as it doesn't follow the standard. They didn't say which compilers though...

About the memcpy thing: MEMCPY was memcpy until someone wanted to be able to override it. So it is still memcpy as long as you want it to be something else. And this should work out of the box.

I'll change the cc.h of the win32 port but other than that, we're OK now.

Thanks for your great work on PPP!

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sun 22 Feb 2015 09:03:16 PM UTC, comment #10: 

> but C4146 seems really wrong. I've added a cast to (long) just after the minus.


I don't think a missing cast qualify as "really wrong", casts are mostly a tool to tell your compiler to "shut up, I know what I'm doing".

Apart from that, thank for fixing this one ;-)

> > C4013 depends on the port I guess.
> No, it doesn't. The default is MEMCPY->memcpy so all files using MEMCPY include <string.h>.


Ah!, I didn't know nor noticed that, thank for fixing this one. I applied the change on other files needing the same fix.

Sylvain

Sylvain Rochet <gradator>
Project Member
Sun 22 Feb 2015 06:41:14 PM UTC, comment #9: 

> Could you try fixing C4310 ?


Unfortunately, I don't know how. I'll have to add these to the ignored warnings.

> C4706 and C4146 are wanted behavior.


I can live with C4706 (but only for the PPP code and because I'd prefer staying as close to the original sources as possible), but C4146 seems really wrong. I've added a cast to (long) just after the minus.

> C4013 depends on the port I guess.


No, it doesn't. The default is MEMCPY->memcpy so all files using MEMCPY include <string.h>.

> And could you try fixing C4028 ?, I don't see why your compiler is complaining.


Oops. I'm working on bug #44069 (udp_sendto and similar don't accept const destination addresses). Seems like I failed to filter out this one.

I'll commit the 2 fixes after bug #44069.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Thu 19 Feb 2015 01:09:18 PM UTC, comment #8: 

And could you try fixing C4028 ?, I don't see why your compiler is complaining.

Sylvain Rochet <gradator>
Project Member
Thu 19 Feb 2015 01:00:59 PM UTC, comment #7: 

Could you try fixing C4310 ?

C4706 and C4146 are wanted behavior.

C4013 depends on the port I guess.

Sylvain Rochet <gradator>
Project Member
Thu 19 Feb 2015 12:41:39 PM UTC, comment #6: 

With VS2010, I get these:
1>\src\netif\ppp\chap-new.c(469): warning C4310: cast truncates constant value
1>\src\netif\ppp\fsm.c(526): warning C4706: assignment within conditional expression
1>\src\netif\ppp\fsm.c(533): warning C4706: assignment within conditional expression
1>\src\netif\ppp\lcp.c(806): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(817): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(1887): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(1925): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(1941): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(2007): warning C4310: cast truncates constant value
1>\src\netif\ppp\lcp.c(2014): warning C4310: cast truncates constant value
1>\src\netif\ppp\ppp.c(437): warning C4028: formal parameter 3 different from declaration
1>\src\netif\ppp\upap.c(551): warning C4310: cast truncates constant value
1>\src\netif\ppp\utils.c(213): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1>\src\netif\ppp\polarssl\md5.c(229): warning C4013: 'memcpy' undefined; assuming extern returning int
1>\src\netif\ppp\pppoe.c(308): warning C4706: assignment within conditional expression

Where C4706 might be OK to ignore.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Wed 18 Feb 2015 10:46:50 PM UTC, comment #5: 

No more compiler warnings for me using GCC.

Sylvain Rochet <gradator>
Project Member
Sun 12 Oct 2014 07:20:08 PM UTC, comment #4: 

> I have to admit it's the first time I'm compiling the PPP code with the win32 project with PPP enabled, but I really get many warnings.
> Is the original code really in that bad shape? Are these our changes or are the warnings in the original code?


Both, but mostly in the original code, pppd is not compiled with -Wextra.  This is not really in bad shape, those warnings are more boring than anything else.

> Also the code uses tabs and spaces mixed, which makes it really hard to read...


Yup, with mixed snake_case and CamelCase, it does not bother me anymore for quite a while, this is several times worse on what I have to deal every day at work, I learnt the hard way to deal with it.

> Anyway, here's a list of warnings I get on current git master (sorry, it's german, I don't have the english VS around right now; you can get the english version from google :):
>
> lwip\src\netif\ppp\polarssl\md5.c(229) : warning C4013: 'memcpy' undefiniert; Annahme: extern mit Rückgabetyp int


Looks like you forgot an #include in your lwipopts.h about the MEMCPY() macro. Note that opt.h defaults to memcpy() without including <string.h>, this is acceptable but wrong anyway.

> lwip\src\netif\ppp\utils.c(212) : warning C4146: Einem vorzeichenlosen Typ wurde ein unärer Minus-Operator zugewiesen. Das Ergebnis ist weiterhin vorzeichenlos.


I added a cast for that, I don't know if your compiler is happy now. gcc does not warn about it, this is expected behavior.

> lwip\src\netif\ppp\utils.c(609) : warning C4100: 'buf': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\utils.c(609) : warning C4100: 'level': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\upap.c(454) : warning C4100: 'id': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\upap.c(488) : warning C4100: 'id': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\ppp.c(1932) : warning C4100: 'pcb': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\ppp.c(2013) : warning C4100: 'mtu': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\lcp.c(2616) : warning C4100: 'id': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\chap-new.c(486) : warning C4100: 'id': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\chap-md5.c(97) : warning C4100: 'private': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\chap-md5.c(95) : warning C4100: 'our_name': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\auth.c(548) : warning C4100: 'pcb': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\auth.c(1083) : warning C4100: 'protocol': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\auth.c(1161) : warning C4100: 'proto': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\auth.c(1211) : warning C4100: 'proto': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\auth.c(1229) : warning C4100: 'proto': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\ipcp.c(2043) : warning C4100: 'replacedefaultroute': Unreferenzierter formaler Parameter


Fixed, however, I still consider it as the least useful warning on earth ;-)

> lwip\src\netif\ppp\upap.c(539) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(841) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(852) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(1067) : warning C4100: 'treat_as_reject': Unreferenzierter formaler Parameter
> lwip\src\netif\ppp\lcp.c(1918) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(1956) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(1972) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(2038) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\lcp.c(2045) : warning C4310: Typumwandlung verkürzt konstante Werte
> lwip\src\netif\ppp\chap-new.c(464) : warning C4310: Typumwandlung verkürzt konstante Werte


I don't know what to do, gcc does not warn about that. Looks like a dumb compiler for me, the following is triggering that:

#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
#define PUTSHORT(s, cp) { \
*(cp)++ = (u_char) ((s) >> 8); \
*(cp)++ = (u_char) (s); \
}
PUTSHORT(PPP_EAP, nakoutp);

lwip\src\netif\ppp\fsm.c(518) : warning C4706: Zuweisung in bedingtem Ausdruck
lwip\src\netif\ppp\fsm.c(525) : warning C4706: Zuweisung in bedingtem Ausdruck

What is wrong with that ?  This is expected behavior where it is currently used.

> There also seem to be some lines using '#if XYZ' checking for non-existent preprocessor macros. This is non-standard (gcc should warn about it) and these macros should be predefined in opt.h or ppp.h.


My fault, fixed.

Sylvain

Sylvain Rochet <gradator>
Project Member
Tue 16 Sep 2014 07:53:01 PM UTC, comment #3: 

There also seem to be some lines using '#if XYZ' checking for non-existent preprocessor macros. This is non-standard (gcc should warn about it) and these macros should be predefined in opt.h or ppp.h.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 16 Sep 2014 07:47:44 PM UTC, comment #2: 

Forget the last comment, I just saw that it's not meant to work ;-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 16 Sep 2014 07:38:44 PM UTC, comment #1: 

Update: ccp.h doesn't event compile as it uses 'bool' which is only available in C++, not in C. Am I doing something wrong here???

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 16 Sep 2014 06:39:35 PM UTC, original submission:  

I have to admit it's the first time I'm compiling the PPP code with the win32 project with PPP enabled, but I really get many warnings. Is the original code really in that bad shape? Are these our changes or are the warnings in the original code?

Also the code uses tabs and spaces mixed, which makes it really hard to read...

Anyway, here's a list of warnings I get on current git master (sorry, it's german, I don't have the english VS around right now; you can get the english version from google :):

lwip\src\netif\ppp\polarssl\md5.c(229) : warning C4013: 'memcpy' undefiniert; Annahme: extern mit Rückgabetyp int
lwip\src\netif\ppp\utils.c(212) : warning C4146: Einem vorzeichenlosen Typ wurde ein unärer Minus-Operator zugewiesen. Das Ergebnis ist weiterhin vorzeichenlos.
lwip\src\netif\ppp\utils.c(609) : warning C4100: 'buf': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\utils.c(609) : warning C4100: 'level': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\upap.c(454) : warning C4100: 'id': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\upap.c(488) : warning C4100: 'id': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\upap.c(539) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\ppp.c(1932) : warning C4100: 'pcb': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\ppp.c(2013) : warning C4100: 'mtu': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\lcp.c(841) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(852) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(1067) : warning C4100: 'treat_as_reject': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\lcp.c(1918) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(1956) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(1972) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(2038) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(2045) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\lcp.c(2616) : warning C4100: 'id': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\ipcp.c(2043) : warning C4100: 'replacedefaultroute': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\fsm.c(518) : warning C4706: Zuweisung in bedingtem Ausdruck
lwip\src\netif\ppp\fsm.c(525) : warning C4706: Zuweisung in bedingtem Ausdruck
lwip\src\netif\ppp\chap-new.c(464) : warning C4310: Typumwandlung verkürzt konstante Werte
lwip\src\netif\ppp\chap-new.c(486) : warning C4100: 'id': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\chap-md5.c(97) : warning C4100: 'private': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\chap-md5.c(95) : warning C4100: 'our_name': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\auth.c(548) : warning C4100: 'pcb': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\auth.c(1083) : warning C4100: 'protocol': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\auth.c(1161) : warning C4100: 'proto': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\auth.c(1211) : warning C4100: 'proto': Unreferenzierter formaler Parameter
lwip\src\netif\ppp\auth.c(1229) : warning C4100: 'proto': Unreferenzierter formaler Parameter

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.

 

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 gradator (Posted a comment)
  • -email is unavailable- added by goldsimon (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-22 goldsimon StatusIn Progress => Fixed
        Open/ClosedOpen => Closed
    2015-02-22 goldsimon StatusNone => In Progress
        Assigned toNone => goldsimon
    2014-10-12 gradator Severity3 - Normal => 1 - Wish
    2014-09-16 goldsimon SummaryNumerous compiler warnings and errors n ppp_new code => Numerous compiler warnings in ppp_new code
    2014-09-16 goldsimon SummaryNumerous compiler warnings in ppp_new code => Numerous compiler warnings and errors n ppp_new code

    Back to the top


    Powered by Savane 3.5