]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Const-correctness in the debug functions!
authorSimon Tatham <anakin@pobox.com>
Sat, 9 May 2015 14:02:45 +0000 (15:02 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 9 May 2015 14:02:45 +0000 (15:02 +0100)
I'm finding missing constifications all over the place this week.
Turns out that dmemdump() has been taking a non-const memory pointer
ever since the beginning, and it's never come up until now. How silly.

misc.c
misc.h

diff --git a/misc.c b/misc.c
index 0d5673b3c6c38f433c0cc7118527a6ad642a1d26..f3a0eeddbe3d33a3e81de95a3d84c0d2454024eb 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -814,7 +814,7 @@ void safefree(void *ptr)
 #ifdef DEBUG
 extern void dputs(char *);             /* defined in per-platform *misc.c */
 
-void debug_printf(char *fmt, ...)
+void debug_printf(const char *fmt, ...)
 {
     char *buf;
     va_list ap;
@@ -827,10 +827,10 @@ void debug_printf(char *fmt, ...)
 }
 
 
-void debug_memdump(void *buf, int len, int L)
+void debug_memdump(const void *buf, int len, int L)
 {
     int i;
-    unsigned char *p = buf;
+    const unsigned char *p = buf;
     char foo[17];
     if (L) {
        int delta;
diff --git a/misc.h b/misc.h
index 2c60748c899a808129e92a38406b6b9d5484aa27..4c6bd7ff684a52e4d3c3599602b06fccb248ca8e 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -109,8 +109,8 @@ int match_ssh_id(int stringlen, const void *string, const char *id);
  */
 
 #ifdef DEBUG
-void debug_printf(char *fmt, ...);
-void debug_memdump(void *buf, int len, int L);
+void debug_printf(const char *fmt, ...);
+void debug_memdump(const void *buf, int len, int L);
 #define debug(x) (debug_printf x)
 #define dmemdump(buf,len) debug_memdump (buf, len, 0);
 #define dmemdumpl(buf,len) debug_memdump (buf, len, 1);