From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 4/6] nbd/server: Add va_list form of nbd_negotiate_send_rep_err()
Date: Wed, 17 Jan 2018 20:26:23 -0600 [thread overview]
Message-ID: <20180118022625.6462-5-eblake@redhat.com> (raw)
In-Reply-To: <20180118022625.6462-1-eblake@redhat.com>
This will be useful for the next patch.
Based on a patch by Vladimir Sementsov-Ogievskiy
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20180110230825.18321-5-eblake@redhat.com>
---
nbd/server.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 31c1d324297..04da1c2f1e1 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -186,18 +186,15 @@ static int nbd_negotiate_send_rep(NBDClient *client, uint32_t type,
/* Send an error reply.
* Return -errno on error, 0 on success. */
-static int GCC_FMT_ATTR(4, 5)
-nbd_negotiate_send_rep_err(NBDClient *client, uint32_t type,
- Error **errp, const char *fmt, ...)
+static int GCC_FMT_ATTR(4, 0)
+nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
+ Error **errp, const char *fmt, va_list va)
{
- va_list va;
char *msg;
int ret;
size_t len;
- va_start(va, fmt);
msg = g_strdup_vprintf(fmt, va);
- va_end(va);
len = strlen(msg);
assert(len < 4096);
trace_nbd_negotiate_send_rep_err(msg);
@@ -217,6 +214,21 @@ out:
return ret;
}
+/* Send an error reply.
+ * Return -errno on error, 0 on success. */
+static int GCC_FMT_ATTR(4, 5)
+nbd_negotiate_send_rep_err(NBDClient *client, uint32_t type,
+ Error **errp, const char *fmt, ...)
+{
+ va_list va;
+ int ret;
+
+ va_start(va, fmt);
+ ret = nbd_negotiate_send_rep_verr(client, type, errp, fmt, va);
+ va_end(va);
+ return ret;
+}
+
/* Send a single NBD_REP_SERVER reply to NBD_OPT_LIST, including payload.
* Return -errno on error, 0 on success. */
static int nbd_negotiate_send_rep_list(NBDClient *client, NBDExport *exp,
--
2.14.3
next prev parent reply other threads:[~2018-01-18 2:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 2:26 [Qemu-devel] [PULL 0/6] NBD patches through 17 Jan Eric Blake
2018-01-18 2:26 ` [Qemu-devel] [PULL 1/6] nbd/server: Hoist nbd_reject_length() earlier Eric Blake
2018-01-18 2:26 ` [Qemu-devel] [PULL 2/6] nbd/server: refactor negotiation functions parameters Eric Blake
2018-01-18 2:26 ` [Qemu-devel] [PULL 3/6] nbd/server: Better error for NBD_OPT_EXPORT_NAME failure Eric Blake
2018-01-18 2:26 ` Eric Blake [this message]
2018-01-18 2:26 ` [Qemu-devel] [PULL 5/6] nbd/server: Add helper functions for parsing option payload Eric Blake
2018-01-18 2:26 ` [Qemu-devel] [PULL 6/6] nbd/server: structurize option reply sending Eric Blake
2018-01-18 16:49 ` [Qemu-devel] [PULL 0/6] NBD patches through 17 Jan Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180118022625.6462-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).