libqtest: Simplify qmp_fd_vsend() a bit
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-9-armbru@redhat.com>
This commit is contained in:
parent
4ff184689b
commit
69f0cb661a
@ -488,24 +488,20 @@ QDict *qtest_qmp_receive(QTestState *s)
|
|||||||
*/
|
*/
|
||||||
void qmp_fd_vsend(int fd, const char *fmt, va_list ap)
|
void qmp_fd_vsend(int fd, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
va_list ap_copy;
|
|
||||||
QObject *qobj;
|
QObject *qobj;
|
||||||
|
|
||||||
/* qobject_from_jsonv() silently eats leading 0xff as invalid
|
/*
|
||||||
* JSON, but we want to test sending them over the wire to force
|
* qobject_from_vjsonf_nofail() chokes on leading 0xff as invalid
|
||||||
* resyncs */
|
* JSON, but tests/test-qga.c needs to send that to test QGA
|
||||||
|
* synchronization
|
||||||
|
*/
|
||||||
if (*fmt == '\377') {
|
if (*fmt == '\377') {
|
||||||
socket_send(fd, fmt, 1);
|
socket_send(fd, fmt, 1);
|
||||||
fmt++;
|
fmt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Going through qobject ensures we escape strings properly.
|
/* Going through qobject ensures we escape strings properly */
|
||||||
* This seemingly unnecessary copy is required in case va_list
|
qobj = qobject_from_vjsonf_nofail(fmt, ap);
|
||||||
* is an array type.
|
|
||||||
*/
|
|
||||||
va_copy(ap_copy, ap);
|
|
||||||
qobj = qobject_from_jsonv(fmt, &ap_copy, &error_abort);
|
|
||||||
va_end(ap_copy);
|
|
||||||
|
|
||||||
/* No need to send anything for an empty QObject. */
|
/* No need to send anything for an empty QObject. */
|
||||||
if (qobj) {
|
if (qobj) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user