Overview
Features
Download
Documentation
Community
Add-Ons & Services

warning reduction

Please post support and help requests here.

warning reduction

Postby killerbot » 14 Mar 2013, 08:49

when using the "-Wshadow" option, we get warning on poco headers.
I would try fix them (not all of them, at least the ones I ran into).

Example of code which gives this warning : class SocketAddress

Code: Select all
   const struct sockaddr* addr() const;

inline    bool SocketAddress::operator == (const SocketAddress& addr) const
{
   return host() == addr.host() && port() == addr.port();
}


inline bool SocketAddress::operator != (const SocketAddress& addr) const
{
   return host() != addr.host() || port() != addr.port();
}


The compiler warns that the 2 'addr' arguments are shadowing the "addr" method.

A suggestion on how to solve it, give the incoming parameter a different name : addrIn

This warning option is a an important one, because often it shows unintended hiding, revealing bugs.

Is it acceptable that the poco code would use such 'In' postfix in the places that give rise to this warning ?
If so, I would fix some of them and provide a pull request with it.

Code: Select all
inline bool SocketAddress::operator != (const SocketAddress& addrIn) const
{
   return host() != addrIn.host() || port() != addrIn.port();
}
killerbot
 
Posts: 66
Joined: 03 Dec 2009, 12:55

Re: warning reduction

Postby alex » 14 Mar 2013, 16:33

More appropriate name would be sockAddr.

Don't hesitate to send pull requests, we very much like to see them because in many cases we get a fix at a price of a mouse click; that is not to say that we do not check the more complicated ones before merging - any potential issues can be discussed in the context of the request itself.
alex
 
Posts: 1117
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: warning reduction

Postby killerbot » 15 Mar 2013, 01:10

a first pull request done, but I think I ran into git problems, since suddenly the commit contains more files then I have touched :-(
Git is beating me around :-(
killerbot
 
Posts: 66
Joined: 03 Dec 2009, 12:55

Re: warning reduction

Postby alex » 17 Mar 2013, 08:31

alex
 
Posts: 1117
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron