[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] Fix verbose packet dumping functions.



-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
>From 4f6c743041996af4e4e31f8895e5840cbacf4905 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones trick home annexia org>
Date: Thu, 17 Sep 2009 14:50:04 +0100
Subject: [PATCH 3/5] Fix verbose packet dumping functions.

This code is normally commented out, because it is too verbose
unless you happen to be debugging the underlying protocol.  Because
it is normally commented out, I found it had bit-rotted slightly.
This commit fixes the obvious problems.
---
 daemon/proto.c |    4 ++--
 src/guestfs.c  |   12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/daemon/proto.c b/daemon/proto.c
index 431f219..817a995 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -83,10 +83,10 @@ main_loop (int _sock)
 
 #if 0
     if (verbose) {
-      int i, j;
+      size_t i, j;
 
       for (i = 0; i < len; i += 16) {
-        printf ("%04x: ", i);
+        printf ("%04zx: ", i);
         for (j = i; j < MIN (i+16, len); ++j)
           printf ("%02x ", (unsigned char) buf[j]);
         for (; j < i+16; ++j)
diff --git a/src/guestfs.c b/src/guestfs.c
index 17974fd..e9961d1 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -1902,18 +1902,18 @@ recv_from_daemon (guestfs_h *g, uint32_t *size_rtn, void **buf_rtn)
   /* Got the full message, caller can start processing it. */
 #if 0
   if (g->verbose) {
-    size_t i, j;
+    ssize_t i, j;
 
     for (i = 0; i < nr; i += 16) {
-      printf ("%04x: ", i);
+      printf ("%04zx: ", i);
       for (j = i; j < MIN (i+16, nr); ++j)
-        printf ("%02x ", (unsigned char) (*buf_rtn)[j]);
+        printf ("%02x ", (*(unsigned char **)buf_rtn)[j]);
       for (; j < i+16; ++j)
         printf ("   ");
       printf ("|");
-      for (j = i; j < MIN (i+16, g->nr); ++j)
-        if (isprint ((*buf_rtn)[j]))
-          printf ("%c", (*buf_rtn)[j]);
+      for (j = i; j < MIN (i+16, nr); ++j)
+        if (isprint ((*(char **)buf_rtn)[j]))
+          printf ("%c", (*(char **)buf_rtn)[j]);
         else
           printf (".");
       for (; j < i+16; ++j)
-- 
1.6.2.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]