[quagga-dev 8662] [PATCH] smux: minor oid optimizations

Stephen Hemminger shemminger at vyatta.com
Wed Apr 6 16:44:17 BST 2011


The code to copy and compare OID values is only used in one file.
By declaring it static, gcc can inline.

---
 lib/smux.c |   12 ++++++------
 lib/smux.h |    7 +++----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/smux.c b/lib/smux.c
index 9421344..52bb9d0 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -79,14 +79,14 @@ static struct cmd_node smux_node =
 /* thread master */
 static struct thread_master *master;
 
-void *
+static void *
 oid_copy (void *dest, const void *src, size_t size)
 {
   return memcpy (dest, src, size * sizeof (oid));
 }
 
 void
-oid2in_addr (oid oid[], int len, struct in_addr *addr)
+oid2in_addr (const oid oid[], int len, struct in_addr *addr)
 {
   int i;
   u_char *pnt;
@@ -101,10 +101,10 @@ oid2in_addr (oid oid[], int len, struct in_addr *addr)
 }
 
 void
-oid_copy_addr (oid oid[], struct in_addr *addr, int len)
+oid_copy_addr (oid oid[], const struct in_addr *addr, int len)
 {
   int i;
-  u_char *pnt;
+  const u_char *pnt;
   
   if (len == 0)
     return;
@@ -115,8 +115,8 @@ oid_copy_addr (oid oid[], struct in_addr *addr, int len)
     oid[i] = *pnt++;
 }
 
-int
-oid_compare (oid *o1, int o1_len, oid *o2, int o2_len)
+static int
+oid_compare (const oid *o1, int o1_len, const oid *o2, int o2_len)
 {
   int i;
 
diff --git a/lib/smux.h b/lib/smux.h
index 92bc3e5..8b25fb9 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -151,9 +151,8 @@ extern int smux_header_generic (struct variable *, oid [], size_t *,
 extern int smux_trap (const oid *, size_t, const oid *, size_t, 
 		      const struct trap_object *, 
                       size_t, unsigned int, u_char);
-extern int oid_compare (oid *, int, oid *, int);
-extern void oid2in_addr (oid [], int, struct in_addr *);
-extern void *oid_copy (void *, const void *, size_t);
-extern void oid_copy_addr (oid [], struct in_addr *, int);
+
+extern void oid2in_addr (const oid [], int, struct in_addr *);
+extern void oid_copy_addr (oid [], const struct in_addr *, int);
 
 #endif /* _ZEBRA_SNMP_H */
-- 
1.7.1




More information about the Quagga-dev mailing list