[PATCH 10/15] libsnmp: Remove ONE_SEC definition

Bart Van Assche <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
Since the ONE_SEC constant is only used in a few places, remove the
definition of this constant and expand the constant where it was used.
---
 agent/mibgroup/agentx/agentx_config.c | 2 +-
 agent/mibgroup/agentx/client.c        | 6 +++---
 include/net-snmp/definitions.h        | 2 --
 snmplib/snmp_api.c                    | 4 ++--
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/agent/mibgroup/agentx/agentx_config.c b/agent/mibgroup/agentx/agentx_config.c
index b590c7a689a4..9c6a1882555b 100644
--- a/agent/mibgroup/agentx/agentx_config.c
+++ b/agent/mibgroup/agentx/agentx_config.c
@@ -127,7 +127,7 @@ agentx_parse_agentx_timeout(const char *token, char *cptr)
         return;
     }
     netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
-                       NETSNMP_DS_AGENT_AGENTX_TIMEOUT, x * ONE_SEC);
+                       NETSNMP_DS_AGENT_AGENTX_TIMEOUT, x * 1000L * 1000L);
 }
 
 void
diff --git a/agent/mibgroup/agentx/client.c b/agent/mibgroup/agentx/client.c
index 7a53301c338d..315f402395b8 100644
--- a/agent/mibgroup/agentx/client.c
+++ b/agent/mibgroup/agentx/client.c
@@ -118,10 +118,10 @@ agentx_open_session(netsnmp_session * ss)
     timeout = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
                                    NETSNMP_DS_AGENT_AGENTX_TIMEOUT);
     if (timeout < 0) 
-    pdu->time = 0;
+        pdu->time = 0;
     else
-	/* for master TIMEOUT is usec, but Agentx Open specifies sec */
-    	pdu->time = timeout/ONE_SEC;
+        /* for master TIMEOUT is usec, but Agentx Open specifies sec */
+        pdu->time = timeout / (1000L * 1000L);
 
     snmp_add_var(pdu, version_sysoid, version_sysoid_len,
 		 's', "Net-SNMP AgentX sub-agent");
diff --git a/include/net-snmp/definitions.h b/include/net-snmp/definitions.h
index 27405c468204..e79aa5d05c6a 100644
--- a/include/net-snmp/definitions.h
+++ b/include/net-snmp/definitions.h
@@ -7,8 +7,6 @@
 
 #define MAX_OID_LEN	    128 /* max subid's in an oid */
 
-#define ONE_SEC         1000000L
-
     /*
      *  For the initial release, this will just refer to the
      *  relevant UCD header files.
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
index 554767a83708..fe7b31fd38cd 100644
--- a/snmplib/snmp_api.c
+++ b/snmplib/snmp_api.c
@@ -186,7 +186,7 @@ static oid      default_enterprise[] = { 1, 3, 6, 1, 4, 1, 3, 1, 1 };
 
 #define DEFAULT_COMMUNITY   "public"
 #define DEFAULT_RETRIES	    5
-#define DEFAULT_TIMEOUT	    ONE_SEC
+#define DEFAULT_TIMEOUT	    (1000L * 1000L)
 #define DEFAULT_REMPORT	    SNMP_PORT
 #define DEFAULT_ENTERPRISE  default_enterprise
 #define DEFAULT_TIME	    0
@@ -1266,7 +1266,7 @@ _sess_copy(netsnmp_session * in_session)
         if (timeout <= 0)
             session->timeout = DEFAULT_TIMEOUT;
         else
-            session->timeout = timeout * ONE_SEC;
+            session->timeout = timeout * 1000L * 1000L;
     }
     session->sessid = snmp_get_next_sessid();
 
-- 
2.16.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.