Re: GCC warnings compiling mib2c output

2009-09-15 Thread Wes Hardaker
> On Mon, 14 Sep 2009 15:44:58 -0400, Christopher Nelson 
>  said:

CN> if (retval) {
CN> ui = SNMP_MALLOC_STRUCT(undoInfo);
ui-> len = retval_len;
CN> memdup((u_char **) & ui->ptr,
CN> (u_char *) retval, ui->len);
CN> }

CN> which I believe is mib2c output, not something we added to the
CN> skeleton.  Has this warning been addressed in later versions?

Later versions haven't changed the code output (at least for that style
(iterator_access) of coding).  You didn't say what line it was
complaining about, though.  I'm guessing the memdup line?
-- 
Wes Hardaker
Cobham Analytic Solutions

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-15 Thread Christopher Nelson
> CN> if (retval) {
> CN> ui = SNMP_MALLOC_STRUCT(undoInfo);
> ui-> len = retval_len;
> CN> memdup((u_char **) & ui->ptr,
> CN> (u_char *) retval, ui->len);
> CN> }
>
> CN> which I believe is mib2c output, not something we added to the
> CN> skeleton.  Has this warning been addressed in later versions?
>
> Later versions haven't changed the code output (at least for that style
> (iterator_access) of coding).  You didn't say what line it was
> complaining about, though.  I'm guessing the memdup line?

Yes, the memdup().

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-16 Thread Dave Shield
2009/9/14 Christopher Nelson :
>   Recently, we upgraded compilers and we're seeing a lot of
> warnings about "dereferencing type-punned pointer will break
> strict-aliasing rules"

Well, the warning is technically correct.
The memdup call *does* re-cast these pointers in a potentially
non-safe manner.   But memdup is working with raw memory,
so this isn't really a problem.

I suppose you could consider tweaking the call to use 'void' rather
than 'char' pointers.   In retrospect, that would have been a better
choice, and might keep your compiler happy.   But note that this
change would have to be applied throughout the whole codebase.

   I'm not sure whether this is something we would be prepared to
do for the standard distributions.   Particularly since it would
presumably impact on third-party code.   Wes - care to comment?

We might also need to consider changing the name at some point
(?to netsnmp_memdup) since a number of other packages also
define a routine "memdup".   Often with a different API template
(typically returning the new buffer as the result of the call, rather
than passing this via the first parameter).
   Again, I'm not sure why we went the way we did, but it's probably
too late to change now.


Dave

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-16 Thread Christopher Nelson
>> Recently, we upgraded compilers and we're seeing a lot of
>> warnings about "dereferencing type-punned pointer will break
>> strict-aliasing rules"
>
> Well, the warning is technically correct.
> The memdup call *does* re-cast these pointers in a potentially
> non-safe manner.   But memdup is working with raw memory,
> so this isn't really a problem.

Probably.

> I suppose you could consider tweaking the call to use 'void' rather
> than 'char' pointers.   In retrospect, that would have been a better
> choice, and might keep your compiler happy.   But note that this
> change would have to be applied throughout the whole codebase.

I'm running up against a local rule that requires our code to compile
without warnings.  I can ask for an exception for the generated code
but maybe I'll do the void -> char change locally; I can't practically
*re*generate the code so I'm not losing any thing.

> ...

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-16 Thread Christopher Nelson
>>> I suppose you could consider tweaking the call to use 'void' rather
>>> than 'char' pointers.   In retrospect, that would have been a better
>>> choice, and might keep your compiler happy.   But note that this
>>> change would have to be applied throughout the whole codebase.
>>
>> I'm running up against a local rule that requires our code to compile
>> without warnings.  I can ask for an exception for the generated code
>> but maybe I'll do the void -> char change locally; I can't practically
>> *re*generate the code so I'm not losing any thing.
>
> Have you already considered adding -fno-strict-aliasing to the list of
> gcc compiler flags ?

I guess that'd be the exception I'd ask for.  Our standard says
"-Wall" with no warnings.

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-16 Thread Bart Van Assche
On Wed, Sep 16, 2009 at 2:08 PM, Christopher Nelson
 wrote:
>> I suppose you could consider tweaking the call to use 'void' rather
>> than 'char' pointers.   In retrospect, that would have been a better
>> choice, and might keep your compiler happy.   But note that this
>> change would have to be applied throughout the whole codebase.
>
> I'm running up against a local rule that requires our code to compile
> without warnings.  I can ask for an exception for the generated code
> but maybe I'll do the void -> char change locally; I can't practically
> *re*generate the code so I'm not losing any thing.

Have you already considered adding -fno-strict-aliasing to the list of
gcc compiler flags ?

Bart.

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: GCC warnings compiling mib2c output

2009-09-16 Thread Bart Van Assche
On Wed, Sep 16, 2009 at 4:07 PM, Christopher Nelson
 wrote:
 I suppose you could consider tweaking the call to use 'void' rather
 than 'char' pointers.   In retrospect, that would have been a better
 choice, and might keep your compiler happy.   But note that this
 change would have to be applied throughout the whole codebase.
>>>
>>> I'm running up against a local rule that requires our code to compile
>>> without warnings.  I can ask for an exception for the generated code
>>> but maybe I'll do the void -> char change locally; I can't practically
>>> *re*generate the code so I'm not losing any thing.
>>
>> Have you already considered adding -fno-strict-aliasing to the list of
>> gcc compiler flags ?
>
> I guess that'd be the exception I'd ask for.  Our standard says
> "-Wall" with no warnings.

My proposal does not contradict your coding standard. Strict aliasing
is a performance optimization present in newer gcc's. According to the
mib2c output that has been posted on this list, it is not safe to
enable this optimization for code generated by mib2c. So you should
disable this optimization via -fno-strict-aliasing. This flag does not
disable any compiler warnings, it disables a compiler transformation.

Please read the section in the gcc manual about -fno-strict-aliasing /
-Wno-strict-aliasing.

Bart.

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users