Eric Blake <ebl...@redhat.com> writes: > All callers have been converted to a form of qmp_cmd() or > qmp_args() that takes the command name with less boilerplate. > Therefore, we also know that all commands are using > interpolation, and can remove an assertion. > > This also means that we have fixed the testsuite to comply with > -Wformat checking on the strings being interpolated for qmp() > (similar to what we previously did for strings used in hmp(), and > matching the checking present on qobject_from_jsonf()). > > Signed-off-by: Eric Blake <ebl...@redhat.com> > --- > tests/libqtest.h | 20 +------------------- > tests/libqtest.c | 32 ++++---------------------------- > 2 files changed, 5 insertions(+), 47 deletions(-) > > diff --git a/tests/libqtest.h b/tests/libqtest.h > index 193adf1eb9..04b36a7b11 100644 > --- a/tests/libqtest.h > +++ b/tests/libqtest.h > @@ -457,15 +457,6 @@ static inline void qtest_end(void) > } > > /** > - * qmp: > - * @fmt...: QMP message to send to qemu; formats arguments through > - * json-lexer.c (only understands '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])'). > - * > - * Sends a QMP message to QEMU and returns the response. > - */ > -QDict *qmp(const char *fmt, ...); > - > -/** > * qmp_raw: > * @msg: Raw QMP message to send to qemu. > * > @@ -474,15 +465,6 @@ QDict *qmp(const char *fmt, ...); > QDict *qmp_raw(const char *msg); > > /** > - * qmp_async: > - * @fmt...: QMP message to send to qemu; formats arguments through > - * json-lexer.c (only understands '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])'). > - * > - * Sends a QMP message to QEMU and leaves the response in the stream. > - */ > -void qmp_async(const char *fmt, ...); > - > -/** > * qmp_cmd: > * @cmd: QMP command, with no arguments. > * > @@ -530,7 +512,7 @@ void qmp_args_async(const char *cmd, const char *fmt, > ...) GCC_FMT_ATTR(2, 3); > /** > * qmp_discard_response: > * > - * Read and discard a QMP response, typically after qmp_async(). > + * Read and discard a QMP response, typically after qmp_cmd_async(). > */ > void qmp_discard_response(void); > > diff --git a/tests/libqtest.c b/tests/libqtest.c > index 5012ecf929..4597d4ac66 100644 > --- a/tests/libqtest.c > +++ b/tests/libqtest.c > @@ -453,17 +453,12 @@ static void qtest_qmp_sendv(QTestState *s, const char > *fmt, va_list ap) > QString *qstr; > const char *str; > > - assert(strstr(fmt, "execute")); > - > /* > - * A round trip through QObject is only needed if % interpolation > - * is used. We interpolate through QObject rather than sprintf in > - * order to escape strings properly. > + * A round trip through QObject (and not sprintf) is needed > + * because % interpolation is used, and we must escape strings > + * properly. > */ > - if (!strchr(fmt, '%')) { > - qmp_fd_send(s->qmp_fd, fmt); > - return; > - } > + assert(strchr(fmt, '%'));
What exactly is wrong with a @fmt that doesn't contain '%'? > > qobj = qobject_from_jsonv(fmt, ap); > qstr = qobject_to_json(qobj); > @@ -833,31 +828,12 @@ void qtest_memset(QTestState *s, uint64_t addr, uint8_t > pattern, size_t size) > qtest_rsp(s, 0); > } > > -QDict *qmp(const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - qtest_qmp_sendv(global_qtest, fmt, ap); > - va_end(ap); > - return qtest_qmp_receive(global_qtest); > -} > - > QDict *qmp_raw(const char *msg) > { > qmp_fd_send(global_qtest->qmp_fd, msg); > return qtest_qmp_receive(global_qtest); > } > > -void qmp_async(const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - qtest_qmp_sendv(global_qtest, fmt, ap); > - va_end(ap); > -} > - > QDict *qmp_cmd(const char *cmd) > { > qmp_cmd_async(cmd);