diff options
author | Eric Blake <eblake@redhat.com> | 2017-09-11 12:20:14 -0500 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2017-09-15 09:05:19 +0200 |
commit | 7b899f4dd596dbb7d271f7fab36fbfffec84868e (patch) | |
tree | 2cc98be4af927083e26c8d40b25d93694eb8cf07 /tests/libqtest.h | |
parent | 4fb609adc91c9352ae72b82cef53002c2e32d7fb (diff) |
qtest: Avoid passing raw strings through hmp()
hmp() passes its string argument through the sprintf() family;
with a proper attribute, gcc -Wformat warns us when we do something
dangerous like passing a non-constant format string. Fortunately,
all our strings were safe, but checking whether the string can
contain an unintended % is easy to avoid and therefore worth doing.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/libqtest.h')
-rw-r--r-- | tests/libqtest.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/libqtest.h b/tests/libqtest.h index 44803d772e..86b3a3bb0d 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -134,14 +134,14 @@ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event); /** * qtest_hmp: * @s: #QTestState instance to operate on. - * @fmt...: HMP command to send to QEMU + * @fmt...: HMP command to send to QEMU, formats arguments like sprintf(). * * Send HMP command to QEMU via QMP's human-monitor-command. * QMP events are discarded. * * Returns: the command's output. The caller should g_free() it. */ -char *qtest_hmp(QTestState *s, const char *fmt, ...); +char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); /** * qtest_hmpv: @@ -592,13 +592,13 @@ static inline QDict *qmp_eventwait_ref(const char *event) /** * hmp: - * @fmt...: HMP command to send to QEMU + * @fmt...: HMP command to send to QEMU, formats arguments like sprintf(). * * Send HMP command to QEMU via QMP's human-monitor-command. * * Returns: the command's output. The caller should g_free() it. */ -char *hmp(const char *fmt, ...); +char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); /** * get_irq: |