On Sat, 2011-04-16 at 17:40 -0500, [email protected] wrote: > I apologize up front for the length of this email. There are two items > I'd like to submit to the net-snmp developers to consider for > improving the software: > > 1) Static analysis results > 2) Avoiding the use of C++ reserved words > > Item 1: > Using an older 5.x series net-snmp on Linux, there was some constant > memory leakage experienced. This leakage was tied to missing > deallocations in error conditions in net-snmp. This situation was > mitigated by upgrading to Net-SNMP 5.6.1 (which fixed at least one of > these leaks) and adding a config parameter to the kernel > (CONFIG_VM_EVENT_COUNTERS), which avoided the other error conditions > that were occurring. In the interest of assisting the project, I ran a > static analysis tool called Cppcheck (an open source C/C++ static > analyzer, which can be found at: > http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) > against a recent revision of trunk (revision 20182) with the thought that it > would be more useful than providing the report based on 5.6.1 (although I > certainly can if desired). The complete list of findings follows the body of > this email. One of Cppcheck's goals is no false positives on items that it > marks as errors (if something is marked incorrectly as an error, the > developers of Cppcheck would appreciate a bug report); so, those markings are > the main ones of concern. I included the full report in the hope that other > levels of findings could be of use. The version of Cppcheck used was 1.48.
The limitations on the depth of ifdef nesting is annoying. Additionally the failure to pick up all include files doesn't help either. Finally it is somewhat odd that you try to run it on the documentation directories as well :-) See below for more comments. > Item 2: > Although there is no C++ in net-snmp, it would be helpful if the use > of C++ reserved words was avoided. For example, class and template are > used as variable names in snmplib/pkcs.c This is not a big issue. Net-SNMP is written in C. With that said all headers should be C++-clean. > and some code generated with mib2c uses this as a variable name. This on the other hand is a bug. Thanks for pointing it out. > Easier integration with C++ would, for example, support writing > subagents in C++ (well make it easier anyway). Please consider this > suggestion. As I usually write my subagents in C++ I can only agree that easing integration with C++ is a good thing. > Hope that helps. > > Thanks, > Eric > > static anaylsis report from Cppcheck version 1.48 on net-snmp trunk, > revision 20182: [Ignored doc files] [Ignored skipped files agent\agent_index.c, agent\agent_read_config.c] > [net-snmp\agent\agent_registry.c:62]: (information) Include file: > "mib_module_includes.h" not found. > [net-snmp\agent\agent_registry.c:65]: (information) Include file: > "agentx/subagent.h" not found. > [net-snmp\agent\agent_registry.c:66]: (information) Include file: > "agentx/client.h" not found. > [net-snmp\agent\agent_registry.c:970] -> [net-snmp\agent > \agent_registry.c:90]: (style) Struct 'lookup_cache' hides typedef > with same name False - In C typedef-names and struct names are in different scopes. > [net-snmp\agent\agent_registry.c:756]: (information) The scope of the > variable 'res' can be reduced > [net-snmp\agent\agent_registry.c:756]: (information) The scope of the > variable 'rc' can be reduced > [net-snmp\agent\agent_registry.c:1115]: (information) The scope of the > variable 'i' can be reduced Correct. > [net-snmp\agent\agent_registry.c:2227]: (information) The scope of the > variable 'i' can be reduced Probably correct but I do not have the energy to care about dump functions. > [net-snmp\agent\agent_registry.c:0]: (information) Interrupted > checking because of too many #ifdef configurations. And there it gives up. > [net-snmp\agent\agent_trap.c:64]: (information) Include file: > "agentx/protocol.h" not found. > [net-snmp\agent\agent_trap.c:1220]: (style) Variable 'arg' is assigned > a value that is never used Correct. > [net-snmp\agent\agent_trap.c:907]: (information) The scope of the > variable 'len' can be reduced Correct. So, that was some down. /MF ------------------------------------------------------------------------------ Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
