Re: [Qemu-block] [PATCH v4 02/11] nbd: More debug typo fixes, use correct formats

2016-06-13 Thread Eric Blake
On 06/13/2016 06:04 AM, Paolo Bonzini wrote:
> 
> 
> On 12/05/2016 00:39, Eric Blake wrote:
>> Clean up some debug message oddities missed earlier; this includes
>> some typos, and recognizing that %d is not necessarily compatible
>> with uint32_t.
> 
> Actually it should be on any POSIX platform, since (by way of the
> requirements on limits.h) POSIX requires sizeof(int) to be >= 4.

Not quite true.  On 32-bit platforms, uint32_t can be 'long' rather than
'int' (I think 32-bit cygwin used to be in this camp, once - I don't
remember if it is still the case).  Thus, PRId32 is NOT necessarily "d"
on all platforms.

> 
> I will apply the patch, but fully expect this to bitrot...
> 
> Paolo
> 
>> Also add a couple messages that I found useful
>> while debugging things.
>>
>> Signed-off-by: Eric Blake 
> 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-block] [PATCH v4 02/11] nbd: More debug typo fixes, use correct formats

2016-06-13 Thread Paolo Bonzini


On 12/05/2016 00:39, Eric Blake wrote:
> Clean up some debug message oddities missed earlier; this includes
> some typos, and recognizing that %d is not necessarily compatible
> with uint32_t.

Actually it should be on any POSIX platform, since (by way of the
requirements on limits.h) POSIX requires sizeof(int) to be >= 4.

I will apply the patch, but fully expect this to bitrot...

Paolo

> Also add a couple messages that I found useful
> while debugging things.
> 
> Signed-off-by: Eric Blake 



[Qemu-block] [PATCH v4 02/11] nbd: More debug typo fixes, use correct formats

2016-05-11 Thread Eric Blake
Clean up some debug message oddities missed earlier; this includes
some typos, and recognizing that %d is not necessarily compatible
with uint32_t. Also add a couple messages that I found useful
while debugging things.

Signed-off-by: Eric Blake 

---
v4: add a couple more tweaks, drop R-b
v3: rebase
---
 nbd/client.c | 41 ++---
 nbd/server.c | 48 +++-
 2 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/nbd/client.c b/nbd/client.c
index 48f2a21..42e4e52 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -109,25 +109,27 @@ static int nbd_handle_reply_err(QIOChannel *ioc, uint32_t 
opt, uint32_t type,

 switch (type) {
 case NBD_REP_ERR_UNSUP:
-TRACE("server doesn't understand request %d, attempting fallback",
-  opt);
+TRACE("server doesn't understand request %" PRIx32
+  ", attempting fallback", opt);
 result = 0;
 goto cleanup;

 case NBD_REP_ERR_POLICY:
-error_setg(errp, "Denied by server for option %x", opt);
+error_setg(errp, "Denied by server for option %" PRIx32, opt);
 break;

 case NBD_REP_ERR_INVALID:
-error_setg(errp, "Invalid data length for option %x", opt);
+error_setg(errp, "Invalid data length for option %" PRIx32, opt);
 break;

 case NBD_REP_ERR_TLS_REQD:
-error_setg(errp, "TLS negotiation required before option %x", opt);
+error_setg(errp, "TLS negotiation required before option %" PRIx32,
+   opt);
 break;

 default:
-error_setg(errp, "Unknown error code when asking for option %x", opt);
+error_setg(errp, "Unknown error code when asking for option %" PRIx32,
+   opt);
 break;
 }

@@ -165,7 +167,7 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, 
Error **errp)
 }
 opt = be32_to_cpu(opt);
 if (opt != NBD_OPT_LIST) {
-error_setg(errp, "Unexpected option type %x expected %x",
+error_setg(errp, "Unexpected option type %" PRIx32 " expected %x",
opt, NBD_OPT_LIST);
 return -1;
 }
@@ -207,7 +209,7 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, 
Error **errp)
 return -1;
 }
 if (namelen > 255) {
-error_setg(errp, "export name length too long %d", namelen);
+error_setg(errp, "export name length too long %" PRIu32, namelen);
 return -1;
 }

@@ -234,7 +236,7 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, 
Error **errp)
 g_free(buf);
 }
 } else {
-error_setg(errp, "Unexpected reply type %x expected %x",
+error_setg(errp, "Unexpected reply type %" PRIx32 " expected %x",
type, NBD_REP_SERVER);
 return -1;
 }
@@ -349,7 +351,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
 }
 opt = be32_to_cpu(opt);
 if (opt != NBD_OPT_STARTTLS) {
-error_setg(errp, "Unexpected option type %x expected %x",
+error_setg(errp, "Unexpected option type %" PRIx32 " expected %x",
opt, NBD_OPT_STARTTLS);
 return NULL;
 }
@@ -361,7 +363,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
 }
 type = be32_to_cpu(type);
 if (type != NBD_REP_ACK) {
-error_setg(errp, "Server rejected request to start TLS %x",
+error_setg(errp, "Server rejected request to start TLS %" PRIx32,
type);
 return NULL;
 }
@@ -373,7 +375,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
 }
 length = be32_to_cpu(length);
 if (length != 0) {
-error_setg(errp, "Start TLS reponse was not zero %x",
+error_setg(errp, "Start TLS response was not zero %" PRIu32,
length);
 return NULL;
 }
@@ -384,7 +386,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
 return NULL;
 }
 data.loop = g_main_loop_new(g_main_context_default(), FALSE);
-TRACE("Starting TLS hanshake");
+TRACE("Starting TLS handshake");
 qio_channel_tls_handshake(tioc,
   nbd_tls_handshake,
   ,
@@ -474,7 +476,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char 
*name, uint32_t *flags,
 }
 globalflags = be16_to_cpu(globalflags);
 *flags = globalflags << 16;
-TRACE("Global flags are %x", globalflags);
+TRACE("Global flags are %" PRIx32, globalflags);
 if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {
 fixedNewStyle = true;
 TRACE("Server supports fixed new style");
@@ -550,7 +552,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char 
*name, uint32_t *flags,
 }
 exportflags = be16_to_cpu(exportflags);
 *flags |= exportflags;
-TRACE("Export