On 16/06/2016 18:02, Peter Maydell wrote:
> Hi. I'm afraid this generates format string warnings on OSX:
Interesting, I did test clang this time. I'll fix it but really this
is a compiler bug. It's *impossible* to pass a short variable
argument, hence va_arg(ap, short) *must* be the same as va_arg(ap, int).
I should start making a list of pointless clang warnings.
Paolo
diff --git a/nbd/server.c b/nbd/server.c
index ba950973..a677e26 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -576,7 +576,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData
*data)
oldStyle = client->exp != NULL && !client->tlscreds;
if (oldStyle) {
assert ((client->exp->nbdflags & ~65535) == 0);
- TRACE("advertising size %" PRIu64 " and flags %" PRIx16,
+ TRACE("advertising size %" PRIu64 " and flags %x",
client->exp->size, client->exp->nbdflags | myflags);
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
stq_be_p(buf + 16, client->exp->size);
@@ -607,7 +607,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData
*data)
}
assert ((client->exp->nbdflags & ~65535) == 0);
- TRACE("advertising size %" PRIu64 " and flags %" PRIx16,
+ TRACE("advertising size %" PRIu64 " and flags %x",
client->exp->size, client->exp->nbdflags | myflags);
stq_be_p(buf + 18, client->exp->size);
stw_be_p(buf + 26, client->exp->nbdflags | myflags);
> /Users/pm215/src/qemu-for-merges/nbd/server.c:580:34: warning: format
> specifies type 'unsigned short' but the argument has type 'unsigned
> int' [-Wformat]
> client->exp->size, client->exp->nbdflags | myflags);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:44:21: note:
> expanded from macro 'TRACE'
> LOG(msg, ## __VA_ARGS__); \
> ^
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:50:50: note:
> expanded from macro 'LOG'
> __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
> ^
> /Users/pm215/src/qemu-for-merges/nbd/server.c:611:34: warning: format
> specifies type 'unsigned short' but the argument has type 'unsigned
> int' [-Wformat]
> client->exp->size, client->exp->nbdflags | myflags);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:44:21: note:
> expanded from macro 'TRACE'
> LOG(msg, ## __VA_ARGS__); \
> ^
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:50:50: note:
> expanded from macro 'LOG'
> __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
> ^
> CC nbd/client.o
> CC nbd/common.o
> CC block/curl.o
> /Users/pm215/src/qemu-for-merges/nbd/client.c:715:57: warning: format
> specifies type 'unsigned short' but the argument has type 'uint32_t'
> (aka 'unsigned int') [-Wformat]
> request->from, request->len, request->handle, request->type);
> ^~~~~~~~~~~~~
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:44:21: note:
> expanded from macro 'TRACE'
> LOG(msg, ## __VA_ARGS__); \
> ^
> /Users/pm215/src/qemu-for-merges/nbd/nbd-internal.h:50:50: note:
> expanded from macro 'LOG'
> __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
> ^