On Sat, 2011-03-26 at 14:08 -0400, Bill Fenner wrote:
> Hi,
> 
> I tried a couple of recent svn checkouts (most recently, r20159), and
> found that net-snmp-features.h isn't installed via "make install":
> 
> 
> In file included from /Users/fenner/tmp/include/net-snmp/types.h:421,
>                  from /Users/fenner/tmp/include/net-snmp/definitions.h:22,
>                  from 
> /Users/fenner/tmp/include/net-snmp/net-snmp-includes.h:67,
>                  from subagent.c:7:
> /Users/fenner/tmp/include/net-snmp/library/snmp_api.h:33:40: error:
> net-snmp/net-snmp-features.h: No such file or directory
> 
> 
> I assume that this is just an oversight, and everyone who's building
> stuff recently is just working inside the source tree.
> 
> Manually copying net-snmp-features.h from includes/net-snmp to
> /Users/fenner/tmp/include/net-snmp/ was sufficient.  Sadly, I haven't
> yet figured out where the Makefile is that does the header
> installation or I would supply a diff, but hopefully this is enough
> info for a developer to fix this for others.

I would suggest that the attached patch is the most correct one but it
is problematic in it's own right.

The effects are that

1) The statistics functions will always exist
1a) Thus the header won't have to be installed and so Bill's problem is
    solved
2) The return value of snmp_increment_statistic* is changed to 1 if the
   counter existed, 0 otherwise. The new value of the counter is not
   available any more (Before it was problematic as it returned false
   fails once in a while).
   The return value of snmp_get_statistic will always be 0
3) The functions will always be provided as stub functions.

Is this patch acceptable?

/MF
Index: snmplib/snmp_api.c
===================================================================
--- snmplib/snmp_api.c	(revision 20159)
+++ snmplib/snmp_api.c	(working copy)
@@ -7300,12 +7300,16 @@
  */
 static u_int    statistics[NETSNMP_STAT_MAX_STATS];
 
+#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
+
 u_int
 snmp_increment_statistic(int which)
 {
     if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
+#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
         statistics[which]++;
-        return statistics[which];
+#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
+        return 1;
     }
     return 0;
 }
@@ -7314,8 +7318,10 @@
 snmp_increment_statistic_by(int which, int count)
 {
     if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
+#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
         statistics[which] += count;
-        return statistics[which];
+#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
+        return 1;
     }
     return 0;
 }
@@ -7323,15 +7329,18 @@
 u_int
 snmp_get_statistic(int which)
 {
+#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
     if (which >= 0 && which < NETSNMP_STAT_MAX_STATS)
         return statistics[which];
+#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
     return 0;
 }
 
 void
 snmp_init_statistics(void)
 {
+#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
     memset(statistics, 0, sizeof(statistics));
+#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
 }
 /**  @} */
-#endif /* NETSNMP_FEATURE_REMOVE_STATISTICS */
Index: include/net-snmp/library/snmp_api.h
===================================================================
--- include/net-snmp/library/snmp_api.h	(revision 20159)
+++ include/net-snmp/library/snmp_api.h	(working copy)
@@ -30,8 +30,6 @@
 #include <net-snmp/pdu_api.h>
 #include <net-snmp/session_api.h>
 
-#include <net-snmp/net-snmp-features.h>
-
 #ifndef DONT_SHARE_ERROR_WITH_OTHER_THREADS
 #define SET_SNMP_ERROR(x) snmp_errno=(x)
 #else
@@ -394,22 +392,13 @@
     oid            *snmp_duplicate_objid(const oid * objToCopy, size_t);
     NETSNMP_IMPORT
 
-#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
     u_int           snmp_increment_statistic(int which);
     NETSNMP_IMPORT
     u_int           snmp_increment_statistic_by(int which, int count);
     NETSNMP_IMPORT
     u_int           snmp_get_statistic(int which);
     void            snmp_init_statistics(void);
-#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,Y)
-#define snmp_init_statistics()
-
-#endif
-
     int             create_user_from_session(netsnmp_session * session);
     int snmp_get_fd_for_session(struct snmp_session *sessp);
     int snmpv3_probe_contextEngineID_rfc5343(void *slp,
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to