On Mon, Feb 28, 2011 at 11:11 PM, Magnus Fromreide <[email protected]>wrote:
> Hello.
>
> The feature remval patches try to replace snmp_increment_statistic and
> snmp_increment_statistic_by with empty macros.
>
> This fails as
> 1. snmp_increment_statistic_by takes two arguments
> 2. Both of them return the resulting value of the statistics
> counter, or 0 on failure. This is actually tested for in various
> places in net-snmp.
>
> The first problem is trivially solvable by means of adding another
> argument.
>
> The second problem is harder, the code tries to check if something went
> wrong but it is perfectly legal for the counters to reach 0 so checking
> for that value is just plain wrong, thus I think a change is needed.
>
> One could make the functions return the next counter value but that
> would make it even harder to pretend that the empty macro is equivalent
> and it would make it hard to pretend that a constant return value is
> correct.
>
> One could make the functions return 1 on success on 0 on failure, but
> that is a bigger ABI change.
>
> One could remove the checks for 0 in the netsnmp code base and go on
> using the current macros (save for issue #1). This preserves the current
> interface but that is arguably less than perfect.
>
> Now I would like some opinions on a reasonable way forward.
>
How about the patch below (not tested) ?
Index: include/net-snmp/library/snmp_api.h
===================================================================
--- include/net-snmp/library/snmp_api.h (revision 20039)
+++ include/net-snmp/library/snmp_api.h (working copy)
@@ -404,8 +404,8 @@ typedef struct request_list {
#else /* NETSNMP_FEATURE_REMOVE_STATISTICS */
/* allow code to continue referencing API even if statistics are removed */
-#define snmp_increment_statistic(X)
-#define snmp_increment_statistic_by(X)
+#define snmp_increment_statistic(which) 1
+#define snmp_increment_statistic_by(which, count) 1
#endif
Bart.
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders