summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/distribute.c7
-rw-r--r--lib/filter.c4
-rw-r--r--lib/hash.c3
-rw-r--r--lib/if.c62
-rw-r--r--lib/if.h63
-rw-r--r--lib/keychain.c14
-rw-r--r--lib/linklist.c12
-rw-r--r--lib/log.h45
-rw-r--r--lib/plist.c4
-rw-r--r--lib/routemap.c2
-rw-r--r--lib/smux.c85
-rw-r--r--lib/smux.h2
-rw-r--r--lib/sockopt.c1
-rw-r--r--lib/sockunion.c3
-rw-r--r--lib/vty.c2
-rw-r--r--lib/vty.h7
-rw-r--r--lib/zassert.h14
-rw-r--r--lib/zclient.c3
18 files changed, 168 insertions, 165 deletions
diff --git a/lib/distribute.c b/lib/distribute.c
index 906e3f6d..242a225c 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -38,12 +38,7 @@ void (*distribute_delete_hook) (struct distribute *);
static struct distribute *
distribute_new (void)
{
- struct distribute *new;
-
- new = XMALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute));
- memset (new, 0, sizeof (struct distribute));
-
- return new;
+ return XCALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute));
}
/* Free distribute object. */
diff --git a/lib/filter.c b/lib/filter.c
index 7aeb8deb..af8d587f 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1857,7 +1857,7 @@ config_write_access (struct vty *vty, afi_t afi)
}
/* Access-list node. */
-struct cmd_node access_node =
+static struct cmd_node access_node =
{
ACCESS_NODE,
"", /* Access list has no interface. */
@@ -1953,7 +1953,7 @@ access_list_init_ipv4 (void)
}
#ifdef HAVE_IPV6
-struct cmd_node access_ipv6_node =
+static struct cmd_node access_ipv6_node =
{
ACCESS_IPV6_NODE,
"",
diff --git a/lib/hash.c b/lib/hash.c
index 3884051f..f705e5dd 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -32,9 +32,8 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *),
struct hash *hash;
hash = XMALLOC (MTYPE_HASH, sizeof (struct hash));
- hash->index = XMALLOC (MTYPE_HASH_INDEX,
+ hash->index = XCALLOC (MTYPE_HASH_INDEX,
sizeof (struct hash_backet *) * size);
- memset (hash->index, 0, sizeof (struct hash_backet *) * size);
hash->size = size;
hash->hash_key = hash_key;
hash->hash_cmp = hash_cmp;
diff --git a/lib/if.c b/lib/if.c
index db590f56..d270c21f 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -320,60 +320,6 @@ if_get_by_name_len(const char *name, size_t namelen)
if_create(name, namelen);
}
-/* Does interface up ? */
-int
-if_is_up (struct interface *ifp)
-{
- return ifp->flags & IFF_UP;
-}
-
-/* Is interface running? */
-int
-if_is_running (struct interface *ifp)
-{
- return ifp->flags & IFF_RUNNING;
-}
-
-/* Is the interface operative, eg. either UP & RUNNING
- or UP & !ZEBRA_INTERFACE_LINK_DETECTION */
-int
-if_is_operative (struct interface *ifp)
-{
- return ((ifp->flags & IFF_UP) &&
- (ifp->flags & IFF_RUNNING || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)));
-}
-
-/* Is this loopback interface ? */
-int
-if_is_loopback (struct interface *ifp)
-{
- /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M
- * but Y on platform N?
- */
- return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL));
-}
-
-/* Does this interface support broadcast ? */
-int
-if_is_broadcast (struct interface *ifp)
-{
- return ifp->flags & IFF_BROADCAST;
-}
-
-/* Does this interface support broadcast ? */
-int
-if_is_pointopoint (struct interface *ifp)
-{
- return ifp->flags & IFF_POINTOPOINT;
-}
-
-/* Does this interface support multicast ? */
-int
-if_is_multicast (struct interface *ifp)
-{
- return ifp->flags & IFF_MULTICAST;
-}
-
/* Printout flag information into log */
const char *
if_flag_dump (unsigned long flag)
@@ -422,7 +368,7 @@ if_flag_dump (unsigned long flag)
/* For debugging */
static void
-if_dump (struct interface *ifp)
+if_dump (const struct interface *ifp)
{
struct listnode *node;
struct connected *c;
@@ -444,7 +390,7 @@ if_dump (struct interface *ifp)
/* Interface printing for all interface. */
void
-if_dump_all ()
+if_dump_all (void)
{
struct listnode *node;
void *p;
@@ -620,9 +566,7 @@ DEFUN (show_address,
struct connected *
connected_new (void)
{
- struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected));
- memset (new, 0, sizeof (struct connected));
- return new;
+ return XCALLOC (MTYPE_CONNECTED, sizeof (struct connected));
}
/* Free connected structure. */
diff --git a/lib/if.h b/lib/if.h
index c99ab81b..9a250906 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -257,13 +257,62 @@ extern void if_delete_retain (struct interface *);
deletes it from the interface list and frees the structure. */
extern void if_delete (struct interface *);
-extern int if_is_up (struct interface *);
-extern int if_is_running (struct interface *);
-extern int if_is_operative (struct interface *);
-extern int if_is_loopback (struct interface *);
-extern int if_is_broadcast (struct interface *);
-extern int if_is_pointopoint (struct interface *);
-extern int if_is_multicast (struct interface *);
+/* Does interface up ? */
+static inline int
+if_is_up (const struct interface *ifp)
+{
+ return ifp->flags & IFF_UP;
+}
+
+/* Is interface running? */
+static inline int
+if_is_running (const struct interface *ifp)
+{
+ return ifp->flags & IFF_RUNNING;
+}
+
+/* Is the interface operative, eg. either UP & RUNNING
+ or UP & !ZEBRA_INTERFACE_LINK_DETECTION */
+static inline int
+if_is_operative (const struct interface *ifp)
+{
+ return ((ifp->flags & IFF_UP) &&
+ (ifp->flags & IFF_RUNNING ||
+ !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)));
+}
+
+/* Is this loopback interface ? */
+static inline int
+if_is_loopback (const struct interface *ifp)
+{
+ /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M
+ * but Y on platform N?
+ */
+ return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL));
+}
+
+/* Does this interface support broadcast ? */
+static inline int
+if_is_broadcast (const struct interface *ifp)
+{
+ return ifp->flags & IFF_BROADCAST;
+}
+
+/* Does this interface support broadcast ? */
+static inline int
+if_is_pointopoint (const struct interface *ifp)
+{
+ return ifp->flags & IFF_POINTOPOINT;
+}
+
+/* Does this interface support multicast ? */
+static inline int
+if_is_multicast (const struct interface *ifp)
+{
+ return ifp->flags & IFF_MULTICAST;
+}
+
+
extern void if_add_hook (int, int (*)(struct interface *));
extern void if_init (void);
extern void if_dump_all (void);
diff --git a/lib/keychain.c b/lib/keychain.c
index 10928b11..6719cebf 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -31,10 +31,7 @@ struct list *keychain_list;
static struct keychain *
keychain_new (void)
{
- struct keychain *new;
- new = XMALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain));
- memset (new, 0, sizeof (struct keychain));
- return new;
+ return XCALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain));
}
static void
@@ -46,10 +43,7 @@ keychain_free (struct keychain *keychain)
static struct key *
key_new (void)
{
- struct key *new;
- new = XMALLOC (MTYPE_KEY, sizeof (struct key));
- memset (new, 0, sizeof (struct key));
- return new;
+ return XCALLOC (MTYPE_KEY, sizeof (struct key));
}
static void
@@ -854,14 +848,14 @@ DEFUN (send_lifetime_duration_month_day,
argv[3], argv[4]);
}
-struct cmd_node keychain_node =
+static struct cmd_node keychain_node =
{
KEYCHAIN_NODE,
"%s(config-keychain)# ",
1
};
-struct cmd_node keychain_key_node =
+static struct cmd_node keychain_key_node =
{
KEYCHAIN_KEY_NODE,
"%s(config-keychain-key)# ",
diff --git a/lib/linklist.c b/lib/linklist.c
index a16e9e18..485a80be 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -28,11 +28,7 @@
struct list *
list_new (void)
{
- struct list *new;
-
- new = XMALLOC (MTYPE_LINK_LIST, sizeof (struct list));
- memset (new, 0, sizeof (struct list));
- return new;
+ return XCALLOC (MTYPE_LINK_LIST, sizeof (struct list));
}
/* Free list. */
@@ -46,11 +42,7 @@ list_free (struct list *l)
static struct listnode *
listnode_new (void)
{
- struct listnode *node;
-
- node = XMALLOC (MTYPE_LINK_NODE, sizeof (struct listnode));
- memset (node, 0, sizeof (struct listnode));
- return node;
+ return XCALLOC (MTYPE_LINK_NODE, sizeof (struct listnode));
}
/* Free listnode. */
diff --git a/lib/log.h b/lib/log.h
index 777fd77d..9708b0d5 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -105,27 +105,48 @@ extern void closezlog (struct zlog *zl);
/* GCC have printf type attribute check. */
#ifdef __GNUC__
-#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((format (printf, a, b)))
#else
#define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */
+#if !(__GNUC__ == 4)
+/* Mark functions as cold. gcc will assume any path leading to a call
+ to them will be unlikely. This means a lot of paths leading up
+ to log messages are easily marked as not likely.
+*/
+#define COLD_ATTRIBUTE __attribute__((__cold__))
+#else
+#define COLD_ATTRIBUTE
+#endif
+
/* Generic function for zlog. */
-extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+extern void zlog (struct zlog *zl, int priority, const char *format, ...)
+ PRINTF_ATTRIBUTE(3, 4);
/* Handy zlog functions. */
-extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_err (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_warn (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_info (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_notice (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_debug (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
/* For bgpd's peer oriented log. */
-extern void plog_err (struct zlog *, const char *format, ...);
-extern void plog_warn (struct zlog *, const char *format, ...);
-extern void plog_info (struct zlog *, const char *format, ...);
-extern void plog_notice (struct zlog *, const char *format, ...);
-extern void plog_debug (struct zlog *, const char *format, ...);
+extern void plog_err (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_warn (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_info (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_notice (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_debug (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
/* Set logging level for the given destination. If the log_level
argument is ZLOG_DISABLED, then the destination is disabled.
diff --git a/lib/plist.c b/lib/plist.c
index 4b498c4d..0f802a83 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -2623,7 +2623,7 @@ prefix_list_reset_orf (void)
/* Prefix-list node. */
-struct cmd_node prefix_node =
+static struct cmd_node prefix_node =
{
PREFIX_NODE,
"", /* Prefix list has no interface. */
@@ -2732,7 +2732,7 @@ prefix_list_init_ipv4 (void)
#ifdef HAVE_IPV6
/* Prefix-list node. */
-struct cmd_node prefix_ipv6_node =
+static struct cmd_node prefix_ipv6_node =
{
PREFIX_IPV6_NODE,
"", /* Prefix list has no interface. */
diff --git a/lib/routemap.c b/lib/routemap.c
index 58ed09a7..5f7a3182 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1280,7 +1280,7 @@ route_map_config_write (struct vty *vty)
}
/* Route map node structure. */
-struct cmd_node rmap_node =
+static struct cmd_node rmap_node =
{
RMAP_NODE,
"%s(config-route-map)# ",
diff --git a/lib/smux.c b/lib/smux.c
index 4a3696c7..95d2e979 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -73,7 +73,7 @@ int debug_smux = 0;
int fail = 0;
/* SMUX node. */
-struct cmd_node smux_node =
+static struct cmd_node smux_node =
{
SMUX_NODE,
"" /* SMUX has no interface. */
@@ -228,7 +228,8 @@ smux_socket ()
}
freeaddrinfo(res0);
if (sock < 0)
- zlog_warn ("Can't connect to SNMP agent with SMUX");
+ if (debug_smux)
+ zlog_debug ("Can't connect to SNMP agent with SMUX");
#else
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
@@ -259,7 +260,8 @@ smux_socket ()
{
close (sock);
smux_sock = -1;
- zlog_warn ("Can't connect to SNMP agent with SMUX");
+ if (debug_smux)
+ zlog_debug ("Can't connect to SNMP agent with SMUX");
return -1;
}
#endif
@@ -324,13 +326,13 @@ smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat,
asn_build_sequence(h1,&length,(u_char)SMUX_GETRSP,ptr-h1e);
if (debug_smux)
- zlog_debug ("SMUX getresp send: %ld", (ptr - buf));
+ zlog_debug ("SMUX getresp send: %td", (ptr - buf));
ret = send (smux_sock, buf, (ptr - buf), 0);
}
-char *
-smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len,
+static u_char *
+smux_var (u_char *ptr, size_t len, oid objid[], size_t *objid_len,
size_t *var_val_len,
u_char *var_val_type,
void **var_value)
@@ -341,14 +343,14 @@ smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len,
u_char *val;
if (debug_smux)
- zlog_debug ("SMUX var parse: len %ld", len);
+ zlog_debug ("SMUX var parse: len %zd", len);
/* Parse header. */
ptr = asn_parse_header (ptr, &len, &type);
if (debug_smux)
{
- zlog_debug ("SMUX var parse: type %d len %ld", type, len);
+ zlog_debug ("SMUX var parse: type %u len %zd", type, len);
zlog_debug ("SMUX var parse: type must be %d",
(ASN_SEQUENCE | ASN_CONSTRUCTOR));
}
@@ -650,8 +652,8 @@ smux_getnext (oid *reqid, size_t *reqid_len, int exact,
}
/* GET message header. */
-char *
-smux_parse_get_header (char *ptr, size_t *len, long *reqid)
+static u_char *
+smux_parse_get_header (u_char *ptr, size_t *len, long *reqid)
{
u_char type;
long errstat;
@@ -667,19 +669,19 @@ smux_parse_get_header (char *ptr, size_t *len, long *reqid)
ptr = asn_parse_int (ptr, len, &type, &errstat, sizeof (errstat));
if (debug_smux)
- zlog_debug ("SMUX GET errstat %ld len: %ld", errstat, *len);
+ zlog_debug ("SMUX GET errstat %ld len: %zd", errstat, *len);
/* Error index. */
ptr = asn_parse_int (ptr, len, &type, &errindex, sizeof (errindex));
if (debug_smux)
- zlog_debug ("SMUX GET errindex %ld len: %ld", errindex, *len);
+ zlog_debug ("SMUX GET errindex %ld len: %zd", errindex, *len);
return ptr;
}
-void
-smux_parse_set (char *ptr, size_t len, int action)
+static void
+smux_parse_set (u_char *ptr, size_t len, int action)
{
long reqid;
oid oid[MAX_OID_LEN];
@@ -690,7 +692,7 @@ smux_parse_set (char *ptr, size_t len, int action)
int ret;
if (debug_smux)
- zlog_debug ("SMUX SET(%s) message parse: len %ld",
+ zlog_debug ("SMUX SET(%s) message parse: len %zd",
(RESERVE1 == action) ? "RESERVE1" : ((FREE == action) ? "FREE" : "COMMIT"),
len);
@@ -709,8 +711,8 @@ smux_parse_set (char *ptr, size_t len, int action)
smux_getresp_send (oid, oid_len, reqid, ret, 3, ASN_NULL, NULL, 0);
}
-void
-smux_parse_get (char *ptr, size_t len, int exact)
+static void
+smux_parse_get (u_char *ptr, size_t len, int exact)
{
long reqid;
oid oid[MAX_OID_LEN];
@@ -721,7 +723,7 @@ smux_parse_get (char *ptr, size_t len, int exact)
int ret;
if (debug_smux)
- zlog_debug ("SMUX GET message parse: len %ld", len);
+ zlog_debug ("SMUX GET message parse: len %zd", len);
/* Parse GET message header. */
ptr = smux_parse_get_header (ptr, &len, &reqid);
@@ -743,8 +745,8 @@ smux_parse_get (char *ptr, size_t len, int exact)
}
/* Parse SMUX_CLOSE message. */
-void
-smux_parse_close (char *ptr, int len)
+static void
+smux_parse_close (u_char *ptr, int len)
{
long reason = 0;
@@ -757,10 +759,10 @@ smux_parse_close (char *ptr, int len)
}
/* SMUX_RRSP message. */
-void
-smux_parse_rrsp (char *ptr, size_t len)
+static void
+smux_parse_rrsp (u_char *ptr, size_t len)
{
- char val;
+ u_char val;
long errstat;
ptr = asn_parse_int (ptr, &len, &val, &errstat, sizeof (errstat));
@@ -770,8 +772,8 @@ smux_parse_rrsp (char *ptr, size_t len)
}
/* Parse SMUX message. */
-int
-smux_parse (char *ptr, size_t len)
+static int
+smux_parse (u_char *ptr, size_t len)
{
/* This buffer we'll use for SOUT message. We could allocate it with
malloc and save only static pointer/lenght, but IMHO static
@@ -791,7 +793,7 @@ process_rest: /* see note below: YYY */
ptr = asn_parse_header (ptr, &len, &type);
if (debug_smux)
- zlog_debug ("SMUX message received type: %d rest len: %ld", type, len);
+ zlog_debug ("SMUX message received type: %d rest len: %zd", type, len);
switch (type)
{
@@ -946,7 +948,7 @@ smux_open (int sock)
u_char *ptr;
size_t len;
u_long version;
- u_char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
+ char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
if (debug_smux)
{
@@ -965,7 +967,7 @@ smux_open (int sock)
version = 0;
ptr = asn_build_int (ptr, &len,
(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- &version, sizeof (version));
+ (long *)&version, sizeof (version));
/* SMUX connection oid. */
ptr = asn_build_objid (ptr, &len,
@@ -977,13 +979,13 @@ smux_open (int sock)
ptr = asn_build_string (ptr, &len,
(u_char)
(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- progname, strlen (progname));
+ (u_char *) progname, strlen (progname));
/* SMUX connection password. */
ptr = asn_build_string (ptr, &len,
(u_char)
(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- smux_passwd, strlen (smux_passwd));
+ (u_char *) smux_passwd, strlen (smux_passwd));
/* Fill in real SMUX header. We exclude ASN header size (2). */
len = BUFSIZ;
@@ -1034,13 +1036,13 @@ smux_trap (oid *name, size_t namelen,
val = SNMP_TRAP_ENTERPRISESPECIFIC;
ptr = asn_build_int (ptr, &len,
(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- &val, sizeof (val));
+ (long *)&val, sizeof (val));
/* Specific trap integer. */
val = sptrap;
ptr = asn_build_int (ptr, &len,
(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- &val, sizeof (val));
+ (long *)&val, sizeof (val));
/* Timeticks timestamp. */
val = 0;
@@ -1181,7 +1183,10 @@ smux_connect (struct thread *t)
int ret;
if (debug_smux)
- zlog_debug ("SMUX connect try %d", fail + 1);
+ {
+ fail = fail + 1;
+ zlog_debug ("SMUX connect try %d", fail);
+ }
/* Clear thread poner of myself. */
smux_connect_thread = NULL;
@@ -1190,8 +1195,10 @@ smux_connect (struct thread *t)
smux_sock = smux_socket ();
if (smux_sock < 0)
{
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ if (debug_smux)
+ zlog_debug ("SMUX socket/connection creation error");
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return 0;
}
@@ -1202,8 +1209,8 @@ smux_connect (struct thread *t)
zlog_warn ("SMUX open message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return -1;
}
@@ -1214,8 +1221,8 @@ smux_connect (struct thread *t)
zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return -1;
}
diff --git a/lib/smux.h b/lib/smux.h
index 79d23e70..11f02e9e 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -39,7 +39,7 @@
#define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
#define SMUX_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
-#define SMUX_MAX_FAILURE 3
+// #define SMUX_MAX_FAILURE 3
/* Structures here are mostly compatible with UCD SNMP 4.1.1 */
#define MATCH_FAILED (-1)
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 4ba7e874..3a25ae1a 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -561,3 +561,4 @@ sockopt_tcp_signature (int sock, union sockunion *su, const char *password)
return -2;
#endif /* HAVE_TCP_MD5SIG */
}
+
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 3750295c..75419b11 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -180,8 +180,7 @@ sockunion_str2su (const char *str)
int ret;
union sockunion *su;
- su = XMALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
- memset (su, 0, sizeof (union sockunion));
+ su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
ret = inet_pton (AF_INET, str, &su->sin.sin_addr);
if (ret > 0) /* Valid IPv4 address format. */
diff --git a/lib/vty.c b/lib/vty.c
index 14a36c16..bfda473d 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1835,6 +1835,7 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port)
}
#endif /* HAVE_IPV6 && ! NRL */
+#if 0
/* Make vty server socket. */
static void
vty_serv_sock_family (const char* addr, unsigned short port, int family)
@@ -1899,6 +1900,7 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family)
/* Add vty server event. */
vty_event (VTY_SERV, accept_sock, NULL);
}
+#endif
#ifdef VTYSH
/* For sockaddr_un. */
diff --git a/lib/vty.h b/lib/vty.h
index 65ae6201..31cbd498 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -141,13 +141,6 @@ struct vty
#define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP)
#endif
-/* GCC have printf type attribute check. */
-#ifdef __GNUC__
-#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
-#else
-#define PRINTF_ATTRIBUTE(a,b)
-#endif /* __GNUC__ */
-
/* Utility macros to convert VTY argument to unsigned long or integer. */
#define VTY_GET_LONG(NAME,V,STR) \
do { \
diff --git a/lib/zassert.h b/lib/zassert.h
index 79126760..123aee16 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -17,9 +17,17 @@ extern void _zlog_assert_failed (const char *assertion, const char *file,
#define __ASSERT_FUNCTION NULL
#endif
-#define zassert(EX) ((void)((EX) ? 0 : \
- (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
- __ASSERT_FUNCTION), 0)))
+#ifdef __GNUC__
+#define UNLIKELY(EX) __builtin_expect(!!(EX), 0)
+#define LIKELY(EX) __builtin_expect(!!(EX), 1)
+#else
+#define UNLIKELY(EX) (EX)
+#define LIKELY(EX) (EX)
+#endif
+
+#define zassert(EX) ((void)(UNLIKELY(EX) ? 0 : \
+ (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
+ __ASSERT_FUNCTION), 0)))
#undef assert
#define assert(EX) zassert(EX)
diff --git a/lib/zclient.c b/lib/zclient.c
index 10e6b5fd..4a716a66 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -49,8 +49,7 @@ struct zclient *
zclient_new ()
{
struct zclient *zclient;
- zclient = XMALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
- memset (zclient, 0, sizeof (struct zclient));
+ zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ);