summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.c3
-rw-r--r--lib/log.c3
-rw-r--r--lib/memory.c2
-rw-r--r--lib/qfstring.c40
-rw-r--r--lib/qtime.c33
-rw-r--r--lib/thread.c12
-rw-r--r--lib/vio_fifo.c2
-rw-r--r--lib/workqueue.h2
8 files changed, 71 insertions, 26 deletions
diff --git a/lib/command.c b/lib/command.c
index 1fc85344..4057bcfc 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -54,7 +54,7 @@ Boston, MA 02111-1307, USA. */
vector node_vector = NULL ;
/*==============================================================================
- * Default motd string.
+ * Default motd string and debug hello message.
*/
static const char* default_motd =
"\n"
@@ -2285,6 +2285,7 @@ cmd_init (bool terminal)
install_element (RESTRICTED_NODE, &show_thread_cpu_cmd);
install_element (VIEW_NODE, &show_thread_cpu_cmd);
install_element (ENABLE_NODE, &show_thread_cpu_cmd);
+
install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
install_element (VIEW_NODE, &show_work_queues_cmd);
install_element (ENABLE_NODE, &show_work_queues_cmd);
diff --git a/lib/log.c b/lib/log.c
index d78c795e..28a04dc9 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -985,6 +985,9 @@ closezlog (struct zlog *zl)
uzlog_set_effective_level(zl) ;
+ if (zl->filename != NULL)
+ free (zl->filename);
+
XFREE (MTYPE_ZLOG, zl);
}
diff --git a/lib/memory.c b/lib/memory.c
index 10e107a3..ef8551cd 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -150,6 +150,8 @@ zmalloc (enum MTYPE mtype, size_t size MEMORY_TRACKER_NAME)
/*------------------------------------------------------------------------------
* Memory allocation zeroising the allocated area.
+ *
+ * As zmalloc, plus zeroises the allocated memory.
*/
void *
zcalloc (enum MTYPE mtype, size_t size MEMORY_TRACKER_NAME)
diff --git a/lib/qfstring.c b/lib/qfstring.c
index 25558797..2d5f69cc 100644
--- a/lib/qfstring.c
+++ b/lib/qfstring.c
@@ -523,23 +523,41 @@ qfs_number(qf_str qfs, uintmax_t val, int sign, enum pf_flags flags,
/* Set up any required sign and radix prefix */
if ((flags & pf_unsigned) || (sign == 0))
- sign_str = "" ;
+ {
+ sign_str = "" ;
+ sign_len = 0 ;
+ }
else if (sign < 0)
- sign_str = "-" ;
+ {
+ sign_str = "-" ;
+ sign_len = 1 ;
+ }
else if (flags & pf_plus)
- sign_str = "+" ;
+ {
+ sign_str = "+" ;
+ sign_len = 1 ;
+ }
else if (flags & pf_space)
- sign_str = " " ;
+ {
+ sign_str = " " ;
+ sign_len = 1 ;
+ }
else
- sign_str = "" ;
-
- sign_len = strlen(sign_str) ;
+ {
+ sign_str = "" ;
+ sign_len = 0 ;
+ } ;
- radix_str = "" ;
if ((flags & (pf_hex | pf_alt)) == (pf_hex | pf_alt))
- radix_str = (flags & pf_uc) ? "0X" : "0x" ;
-
- radix_len = strlen(radix_str) ;
+ {
+ radix_str = (flags & pf_uc) ? "0X" : "0x" ;
+ radix_len = 2 ;
+ }
+ else
+ {
+ radix_str = "" ;
+ radix_len = 0 ;
+ } ;
/* Turn off zero fill if left justify (width < 0) */
if (width < 0)
diff --git a/lib/qtime.c b/lib/qtime.c
index 789ced1e..d1283198 100644
--- a/lib/qtime.c
+++ b/lib/qtime.c
@@ -72,15 +72,37 @@
* (But seems unlikely that such a system would not support CLOCK_MONOTONIC !)
*
* When clock_t is a 32-bit integer must be at least ready for wrap around.
- * There are two cases:
+ * We take the clock_t signed values and widen to 64-bit signed, so we have
+ * the current sample (this) and the previous one (last), and two cases to
+ * consider:
*
- * * +ve wrap around. new < old value, and new >= 0
+ * * +ve wrap around -- so value is 31-bit unsigned, and wraps from large
+ * +ve value to small +ve value.
*
- * step = (INT32_MAX - old + 1) + new
+ * step = this - last will be -ve
*
- * * -ve wrap around. new < old value, and new < 0 (and old > 0)
+ * 'last' will be some value ((INT32_MAX + 1) - x), and 'this' will be some
+ * (relatively) small value y. The step is x + y, we have:
*
- * step = (INT32_MAX - old + 1) - (INT32_MIN - new)
+ * step = y - ((INT32_MAX + 1) - x) = (x + y) - (INT32_MAX + 1)
+ *
+ * so we correct by adding (INT32_MAX + 1).
+ *
+ * * -ve wrap around -- so value is 32-bit signed, and wraps from a large
+ * +ve value to a very -ve value.
+ *
+ * step = this - last will be -ve
+ *
+ * 'last will' be some value (INT32_MAX + 1) - x, and 'this' will be some
+ * value (y - (INT32_MAX + 1)). The step is x + y, we have:
+ *
+ * step = (y - (INT32_MAX + 1)) - ((INT32_MAX + 1) - x)
+ * = (x + y) - 2 * (INT32_MAX + 1)
+ *
+ * so we correct by adding (INT32_MAX + 1).
+ *
+ * In both cases the wrap around gives an apparently -ve 'step', and that is
+ * corrected by adding (INT32_MAX + 1) until it goes +ve.
*
* In any event, a step > 24 hours is taken to means that something has gone
* very, very badly wrong.
@@ -340,4 +362,3 @@ qt_random(uint32_t seed)
* or the last entry, and have done with it.
*/
-
diff --git a/lib/thread.c b/lib/thread.c
index 90aad4ba..b9fd603c 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -1280,13 +1280,13 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
/* Calculate select wait timer if nothing else to do */
if (m->ready.count == 0)
{
- quagga_get_relative (NULL);
- timer_wait = thread_timer_wait (&m->timer, &timer_val);
- timer_wait_bg = thread_timer_wait (&m->background, &timer_val_bg);
+ quagga_get_relative (NULL);
+ timer_wait = thread_timer_wait (&m->timer, &timer_val);
+ timer_wait_bg = thread_timer_wait (&m->background, &timer_val_bg);
- if (timer_wait_bg &&
- (!timer_wait || (timeval_cmp (*timer_wait, *timer_wait_bg) > 0)))
- timer_wait = timer_wait_bg;
+ if (timer_wait_bg &&
+ (!timer_wait || (timeval_cmp (*timer_wait, *timer_wait_bg) > 0)))
+ timer_wait = timer_wait_bg;
}
else
{
diff --git a/lib/vio_fifo.c b/lib/vio_fifo.c
index 52e0d2df..65f19411 100644
--- a/lib/vio_fifo.c
+++ b/lib/vio_fifo.c
@@ -332,7 +332,7 @@ vio_fifo_new(ulen size)
if (vio_fifo_debug)
size = 29 ;
- total_size = offsetof(struct vio_fifo, own_lump->data[size]) ;
+ total_size = offsetof(struct vio_fifo, own_lump[0].data[size]) ;
vff = XCALLOC(MTYPE_VIO_FIFO, total_size) ;
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 15e08804..46f27734 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -27,7 +27,7 @@
#include "misc.h"
/* Hold time for the initial schedule of a queue run, in millisec */
-enum { WORK_QUEUE_DEFAULT_HOLD = 50 } ;
+enum { WORK_QUEUE_DEFAULT_HOLD = 50 } ;
/* action value, for use by item processor and item error handlers */
typedef enum