From: Donald Sharp Date: Wed, 25 May 2016 23:14:36 +0000 (-0400) Subject: lib: Fix compile warnings with zlog_hexdump X-Git-Tag: frr-2.0-rc1~813 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a9b5cbe55a6b3dea02867382a1855b591cf855b3;p=mirror%2Ffrr.git lib: Fix compile warnings with zlog_hexdump When using zlog_hexdump tell the compiler that we don't expect to actually change the memory. Signed-off-by: Donald Sharp --- diff --git a/lib/log.c b/lib/log.c index 5d673e2166..fd31c9b975 100644 --- a/lib/log.c +++ b/lib/log.c @@ -992,7 +992,7 @@ proto_redistnum(int afi, const char *s) } void -zlog_hexdump (void *mem, unsigned int len) { +zlog_hexdump (const void *mem, unsigned int len) { unsigned long i = 0; unsigned int j = 0; unsigned int columns = 8; @@ -1007,7 +1007,7 @@ zlog_hexdump (void *mem, unsigned int len) { /* print hex data */ if (i < len) - s += sprintf(s, "%02x ", 0xFF & ((char*)mem)[i]); + s += sprintf(s, "%02x ", 0xFF & ((const char*)mem)[i]); /* end of block, just aligning for ASCII dump */ else @@ -1021,8 +1021,8 @@ zlog_hexdump (void *mem, unsigned int len) { if (j >= len) /* end of block, not really printing */ s += sprintf(s, " "); - else if(isprint((int)((char*)mem)[j])) /* printable char */ - s += sprintf(s, "%c", 0xFF & ((char*)mem)[j]); + else if(isprint((int)((const char *)mem)[j])) /* printable char */ + s += sprintf(s, "%c", 0xFF & ((const char *)mem)[j]); else /* other char */ s += sprintf(s, "."); diff --git a/lib/log.h b/lib/log.h index f22be2318f..61370f7b82 100644 --- a/lib/log.h +++ b/lib/log.h @@ -176,7 +176,7 @@ extern void zlog_backtrace_sigsafe(int priority, void *program_counter); extern size_t quagga_timestamp(int timestamp_precision /* # subsecond digits */, char *buf, size_t buflen); -extern void zlog_hexdump(void *mem, unsigned int len); +extern void zlog_hexdump(const void *mem, unsigned int len); /* structure useful for avoiding repeated rendering of the same timestamp */ struct timestamp_control {