Received: from eggs.gnu.org ([2001:4830:134:3::10]:43355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoqAN-0007nc-Ss for qemu-devel@nongnu.org; Sat, 09 Apr 2016 06:31:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoqAI-0000yl-SV for qemu-devel@nongnu.org; Sat, 09 Apr 2016 06:30:59 -0400 Received: from mail.avalus.com ([89.16.176.221]:60805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoqAI-0000yd-GO for qemu-devel@nongnu.org; Sat, 09 Apr 2016 06:30:54 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) From: Alex Bligh In-Reply-To: <1460153158-21612-4-git-send-email-eblake@redhat.com> Date: Sat, 9 Apr 2016 11:30:53 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1460153158-21612-1-git-send-email-eblake@redhat.com> <1460153158-21612-4-git-send-email-eblake@redhat.com> Subject: Re: [Qemu-devel] [PATCH 03/18] nbd: More debug typo fixes, use correct formats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Alex Bligh , "qemu-devel@nongnu.org" , Paolo Bonzini On 8 Apr 2016, at 23:05, Eric Blake wrote: > Clean up some debug message oddities missed earlier; this includes > both typos, and recognizing that %d is not necessarily compatible > with uint32_t. >=20 > Signed-off-by: Eric Blake Reviewed-by: Alex Bligh > --- > nbd/client.c | 41 ++++++++++++++++++++++------------------- > nbd/server.c | 44 +++++++++++++++++++++++--------------------- > 2 files changed, 45 insertions(+), 40 deletions(-) >=20 > 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, >=20 > 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 =3D 0; > goto cleanup; >=20 > 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; >=20 > 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; >=20 > 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; >=20 > 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; > } >=20 > @@ -165,7 +167,7 @@ static int nbd_receive_list(QIOChannel *ioc, char = **name, Error **errp) > } > opt =3D be32_to_cpu(opt); > if (opt !=3D 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; > } >=20 > @@ -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 =3D be32_to_cpu(opt); > if (opt !=3D 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 =3D be32_to_cpu(type); > if (type !=3D 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 =3D be32_to_cpu(length); > if (length !=3D 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 =3D 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, > &data, > @@ -474,7 +476,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, const = char *name, uint32_t *flags, > } > globalflags =3D be16_to_cpu(globalflags); > *flags =3D globalflags << 16; > - TRACE("Global flags are %x", globalflags); > + TRACE("Global flags are %" PRIx32, globalflags); > if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { > fixedNewStyle =3D true; > TRACE("Server supports fixed new style"); > @@ -550,7 +552,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, const = char *name, uint32_t *flags, > } > exportflags =3D be16_to_cpu(exportflags); > *flags |=3D exportflags; > - TRACE("Export flags are %x", exportflags); > + TRACE("Export flags are %" PRIx16, exportflags); > } else if (magic =3D=3D NBD_CLIENT_MAGIC) { > if (name) { > error_setg(errp, "Server does not support export names"); > @@ -683,7 +685,8 @@ ssize_t nbd_send_request(QIOChannel *ioc, struct = nbd_request *request) > ssize_t ret; >=20 > TRACE("Sending request to server: " > - "{ .from =3D %" PRIu64", .len =3D %u, .handle =3D %" = PRIu64", .type=3D%i}", > + "{ .from =3D %" PRIu64", .len =3D %" PRIu32 ", .handle =3D = %" PRIu64 > + ", .type=3D%" PRIu16 " }", > request->from, request->len, request->handle, = request->type); >=20 > cpu_to_be32w((uint32_t*)buf, NBD_REQUEST_MAGIC); > @@ -732,12 +735,12 @@ ssize_t nbd_receive_reply(QIOChannel *ioc, = struct nbd_reply *reply) >=20 > reply->error =3D nbd_errno_to_system_errno(reply->error); >=20 > - TRACE("Got reply: " > - "{ magic =3D 0x%x, .error =3D %d, handle =3D %" PRIu64" }", > + TRACE("Got reply: { magic =3D 0x%" PRIx32 ", .error =3D % " = PRId32 > + ", handle =3D %" PRIu64" }", > magic, reply->error, reply->handle); >=20 > if (magic !=3D NBD_REPLY_MAGIC) { > - LOG("invalid magic (got 0x%x)", magic); > + LOG("invalid magic (got 0x%" PRIx32 ")", magic); > return -EINVAL; > } > return 0; > diff --git a/nbd/server.c b/nbd/server.c > index e7e4881..81afae2 100644 > --- a/nbd/server.c > +++ b/nbd/server.c > @@ -196,7 +196,7 @@ static int nbd_negotiate_send_rep(QIOChannel *ioc, = uint32_t type, uint32_t opt) > uint64_t magic; > uint32_t len; >=20 > - TRACE("Reply opt=3D%x type=3D%x", type, opt); > + TRACE("Reply opt=3D%" PRIx32 " type=3D%" PRIx32, type, opt); >=20 > magic =3D cpu_to_be64(NBD_REP_MAGIC); > if (nbd_negotiate_write(ioc, &magic, sizeof(magic)) !=3D = sizeof(magic)) { > @@ -226,7 +226,7 @@ static int nbd_negotiate_send_rep_list(QIOChannel = *ioc, NBDExport *exp) > uint64_t magic, name_len; > uint32_t opt, type, len; >=20 > - TRACE("Advertizing export name '%s'", exp->name ? exp->name : = ""); > + TRACE("Advertising export name '%s'", exp->name ? exp->name : = ""); > name_len =3D strlen(exp->name); > magic =3D cpu_to_be64(NBD_REP_MAGIC); > if (nbd_negotiate_write(ioc, &magic, sizeof(magic)) !=3D = sizeof(magic)) { > @@ -392,12 +392,12 @@ static int nbd_negotiate_options(NBDClient = *client) > TRACE("Checking client flags"); > be32_to_cpus(&flags); > if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) { > - TRACE("Support supports fixed newstyle handshake"); > + TRACE("Client supports fixed newstyle handshake"); > fixedNewstyle =3D true; > flags &=3D ~NBD_FLAG_C_FIXED_NEWSTYLE; > } > if (flags !=3D 0) { > - TRACE("Unknown client flags 0x%x received", flags); > + TRACE("Unknown client flags 0x%" PRIx32 " received", flags); > return -EIO; > } >=20 > @@ -431,12 +431,12 @@ static int nbd_negotiate_options(NBDClient = *client) > } > length =3D be32_to_cpu(length); >=20 > - TRACE("Checking option 0x%x", clientflags); > + TRACE("Checking option 0x%" PRIx32, clientflags); > if (client->tlscreds && > client->ioc =3D=3D (QIOChannel *)client->sioc) { > QIOChannel *tioc; > if (!fixedNewstyle) { > - TRACE("Unsupported option 0x%x", clientflags); > + TRACE("Unsupported option 0x%" PRIx32, clientflags); > return -EINVAL; > } > switch (clientflags) { > @@ -450,7 +450,8 @@ static int nbd_negotiate_options(NBDClient = *client) > break; >=20 > default: > - TRACE("Option 0x%x not permitted before TLS", = clientflags); > + TRACE("Option 0x%" PRIx32 " not permitted before = TLS", > + clientflags); > if (nbd_negotiate_drop_sync(client->ioc, length) !=3D = length) { > return -EIO; > } > @@ -488,7 +489,7 @@ static int nbd_negotiate_options(NBDClient = *client) > } > break; > default: > - TRACE("Unsupported option 0x%x", clientflags); > + TRACE("Unsupported option 0x%" PRIx32, clientflags); > if (nbd_negotiate_drop_sync(client->ioc, length) !=3D = length) { > return -EIO; > } > @@ -506,7 +507,7 @@ static int nbd_negotiate_options(NBDClient = *client) > return nbd_negotiate_handle_export_name(client, = length); >=20 > default: > - TRACE("Unsupported option 0x%x", clientflags); > + TRACE("Unsupported option 0x%" PRIx32, clientflags); > return -EINVAL; > } > } > @@ -647,12 +648,12 @@ static ssize_t nbd_receive_request(QIOChannel = *ioc, struct nbd_request *request) > request->from =3D be64_to_cpup((uint64_t*)(buf + 16)); > request->len =3D be32_to_cpup((uint32_t*)(buf + 24)); >=20 > - TRACE("Got request: " > - "{ magic =3D 0x%x, .type =3D %d, from =3D %" PRIu64" , len = =3D %u }", > + TRACE("Got request: { magic =3D 0x%" PRIx32 ", .type =3D %" = PRIx32 > + ", from =3D %" PRIu64 " , len =3D %" PRIu32 " }", > magic, request->type, request->from, request->len); >=20 > if (magic !=3D NBD_REQUEST_MAGIC) { > - LOG("invalid magic (got 0x%x)", magic); > + LOG("invalid magic (got 0x%" PRIx32 ")", magic); > return -EINVAL; > } > return 0; > @@ -665,7 +666,8 @@ static ssize_t nbd_send_reply(QIOChannel *ioc, = struct nbd_reply *reply) >=20 > reply->error =3D system_errno_to_nbd_errno(reply->error); >=20 > - TRACE("Sending response to client: { .error =3D %d, handle =3D %" = PRIu64 " }", > + TRACE("Sending response to client: { .error =3D %" PRId32 > + ", handle =3D %" PRIu64 " }", > reply->error, reply->handle); >=20 > /* Reply > @@ -994,7 +996,7 @@ static ssize_t nbd_co_receive_request(NBDRequest = *req, struct nbd_request *reque > command =3D request->type & NBD_CMD_MASK_COMMAND; > if (command =3D=3D NBD_CMD_READ || command =3D=3D NBD_CMD_WRITE) { > if (request->len > NBD_MAX_BUFFER_SIZE) { > - LOG("len (%u) is larger than max len (%u)", > + LOG("len (%" PRIu32" ) is larger than max len (%u)", > request->len, NBD_MAX_BUFFER_SIZE); > rc =3D -EINVAL; > goto out; > @@ -1007,7 +1009,7 @@ static ssize_t nbd_co_receive_request(NBDRequest = *req, struct nbd_request *reque > } > } > if (command =3D=3D NBD_CMD_WRITE) { > - TRACE("Reading %u byte(s)", request->len); > + TRACE("Reading %" PRIu32 " byte(s)", request->len); >=20 > if (read_sync(client->ioc, req->data, request->len) !=3D = request->len) { > LOG("reading from socket failed"); > @@ -1057,10 +1059,10 @@ static void nbd_trip(void *opaque) > } > command =3D request.type & NBD_CMD_MASK_COMMAND; > if (command !=3D NBD_CMD_DISC && (request.from + request.len) > = exp->size) { > - LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64 > - ", Offset: %" PRIu64 "\n", > - request.from, request.len, > - (uint64_t)exp->size, (uint64_t)exp->dev_offset); > + LOG("From: %" PRIu64 ", Len: %" PRIu32", Size: %" PRIu64 > + ", Offset: %" PRIu64 "\n", > + request.from, request.len, > + (uint64_t)exp->size, (uint64_t)exp->dev_offset); > LOG("requested operation past EOF--bad client?"); > goto invalid_request; > } > @@ -1095,7 +1097,7 @@ static void nbd_trip(void *opaque) > goto error_reply; > } >=20 > - TRACE("Read %u byte(s)", request.len); > + TRACE("Read %" PRIu32" byte(s)", request.len); > if (nbd_co_send_reply(req, &reply, request.len) < 0) > goto out; > break; > @@ -1162,7 +1164,7 @@ static void nbd_trip(void *opaque) > } > break; > default: > - LOG("invalid request type (%u) received", request.type); > + LOG("invalid request type (%" PRIu32 ") received", = request.type); > invalid_request: > reply.error =3D EINVAL; > error_reply: > --=20 > 2.5.5 >=20 >=20 --=20 Alex Bligh