From 6c4f4e6e6a00d412f2c683f0a4232389ee7235f8 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 3 Mar 2015 08:51:53 +0100 Subject: *: use void * for printing pointers On higher warning levels, compilers expect %p printf arguments to be void *. Since format string / argument warnings can be useful otherwise, let's get rid of this noise by sprinkling casts to void * over printf calls. Signed-off-by: David Lamparter --- lib/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/buffer.c') diff --git a/lib/buffer.c b/lib/buffer.c index 45e2e1c508..b689549ed6 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -322,7 +322,8 @@ buffer_flush_window (struct buffer *b, int fd, int width, int height, /* This should absolutely never occur. */ zlog_err("%s: corruption detected: iov_small overflowed; " "head %p, tail %p, head->next %p", - __func__, b->head, b->tail, b->head->next); + __func__, (void *)b->head, (void *)b->tail, + (void *)b->head->next); iov = XMALLOC(MTYPE_TMP, iov_alloc*sizeof(*iov)); memcpy(iov, small_iov, sizeof(small_iov)); } -- cgit v1.2.3 From f03db93b27bc4221712a2f7ef6a123a144e5884c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 3 Mar 2015 09:08:05 +0100 Subject: lib, vtysh: reduce unneccessary C extension usage We're only supporting GCC, Clang and ICC; but there's no reason to use nonstandard C constructs if they don't actually provide any benefit. Signed-off-by: David Lamparter (cherry picked from commit 71f55f38cb3dd804176e7f382f52b75ddcd437de) --- lib/buffer.c | 2 +- vtysh/vtysh_main.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/buffer.c') diff --git a/lib/buffer.c b/lib/buffer.c index b689549ed6..ee9310100e 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -148,7 +148,7 @@ buffer_add (struct buffer *b) { struct buffer_data *d; - d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data, data[b->size])); + d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data, data) + b->size); d->cp = d->sp = 0; d->next = NULL; diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 1d40ab4cca..667c88e576 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -231,9 +231,12 @@ static void log_it(const char *line) { time_t t = time(NULL); struct tm *tmp = localtime(&t); - const char *user = getenv("USER") ? : "boot"; + const char *user = getenv("USER"); char tod[64]; + if (!user) + user = "boot"; + strftime(tod, sizeof tod, "%Y%m%d-%H:%M.%S", tmp); fprintf(logfile, "%s:%s %s\n", tod, user, line); -- cgit v1.2.3