]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Fix compile warnings with zlog_hexdump
authorDonald Sharp <sharpd@cumulusnetwroks.com>
Wed, 25 May 2016 23:14:36 +0000 (19:14 -0400)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 26 May 2016 00:38:35 +0000 (20:38 -0400)
When using zlog_hexdump tell the compiler that we don't expect
to actually change the memory.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/log.c
lib/log.h

index 5d673e21665645787227bc60110e86a56251e1c4..fd31c9b9753c82775073a05e0be8e0481c7462d8 100644 (file)
--- 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, ".");
index f22be2318fcfe22d834622621fe39895e202e350..61370f7b82766e30325927e9f46fc334dc701a65 100644 (file)
--- 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 {