[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 20/20] libqtest: Enable compile-time format stri
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH 20/20] libqtest: Enable compile-time format string checking |
Date: |
Thu, 12 Jul 2018 11:16:25 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 |
On 07/12/2018 08:12 AM, Markus Armbruster wrote:
> qtest_qmp() & friends pass their format string and variable arguments
> to qobject_from_vjsonf_nofail(). Unlike qobject_from_jsonv(), they
> aren't decorated with GCC_FMT_ATTR(). Fix that to get compile-time
> format string checking.
>
> Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> tests/libqtest.h | 32 +++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/tests/libqtest.h b/tests/libqtest.h
> index 68b767fc88..087d6793eb 100644
> --- a/tests/libqtest.h
> +++ b/tests/libqtest.h
> @@ -81,7 +81,8 @@ void qtest_quit(QTestState *s);
> *
> * Sends a QMP message to QEMU and consumes the response.
> */
> -void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);
> +void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
> + GCC_FMT_ATTR(2, 3);
>
> /**
> * qtest_qmp:
> @@ -91,7 +92,8 @@ void qtest_qmp_discard_response(QTestState *s, const char
> *fmt, ...);
> *
> * Sends a QMP message to QEMU and returns the response.
> */
> -QDict *qtest_qmp(QTestState *s, const char *fmt, ...);
> +QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
> + GCC_FMT_ATTR(2, 3);
>
> /**
> * qtest_qmp_send:
> @@ -101,7 +103,8 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...);
> *
> * Sends a QMP message to QEMU and leaves the response in the stream.
> */
> -void qtest_qmp_send(QTestState *s, const char *fmt, ...);
> +void qtest_qmp_send(QTestState *s, const char *fmt, ...)
> + GCC_FMT_ATTR(2, 3);
>
> /**
> * qtest_qmpv_discard_response:
> @@ -112,7 +115,8 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ...);
> *
> * Sends a QMP message to QEMU and consumes the response.
> */
> -void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);
> +void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
> + GCC_FMT_ATTR(2, 0);
>
> /**
> * qtest_qmpv:
> @@ -123,7 +127,8 @@ void qtest_qmpv_discard_response(QTestState *s, const
> char *fmt, va_list ap);
> *
> * Sends a QMP message to QEMU and returns the response.
> */
> -QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
> +QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
> + GCC_FMT_ATTR(2, 0);
>
> /**
> * qtest_qmp_vsend:
> @@ -134,7 +139,8 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list
> ap);
> *
> * Sends a QMP message to QEMU and leaves the response in the stream.
> */
> -void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap);
> +void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
> + GCC_FMT_ATTR(2, 0);
>
> /**
> * qtest_receive:
> @@ -590,7 +596,7 @@ static inline void qtest_end(void)
> *
> * Sends a QMP message to QEMU and returns the response.
> */
> -QDict *qmp(const char *fmt, ...);
> +QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
>
> /**
> * qmp_send:
> @@ -599,7 +605,7 @@ QDict *qmp(const char *fmt, ...);
> *
> * Sends a QMP message to QEMU and leaves the response in the stream.
> */
> -void qmp_send(const char *fmt, ...);
> +void qmp_send(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
>
> /**
> * qmp_discard_response:
> @@ -608,7 +614,7 @@ void qmp_send(const char *fmt, ...);
> *
> * Sends a QMP message to QEMU and consumes the response.
> */
> -void qmp_discard_response(const char *fmt, ...);
> +void qmp_discard_response(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
>
> /**
> * qmp_receive:
> @@ -967,10 +973,10 @@ static inline int64_t clock_set(int64_t val)
> }
>
> QDict *qmp_fd_receive(int fd);
> -void qmp_fd_vsend(int fd, const char *fmt, va_list ap);
> -void qmp_fd_send(int fd, const char *fmt, ...);
> -QDict *qmp_fdv(int fd, const char *fmt, va_list ap);
> -QDict *qmp_fd(int fd, const char *fmt, ...);
> +void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
> +void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
> +QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
> +QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
>
> /**
> * qtest_cb_for_every_machine:
>
- [Qemu-devel] [PATCH 04/20] libqtest: Clean up how we read the QMP greeting, (continued)
- [Qemu-devel] [PATCH 04/20] libqtest: Clean up how we read the QMP greeting, Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 10/20] tests: Pass literal format strings directly to qmp_FOO(), Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 07/20] libqtest: Simplify qmp_fd_vsend() a bit, Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 17/20] migration-test: Clean up string interpolation into QMP, part 1, Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 20/20] libqtest: Enable compile-time format string checking, Markus Armbruster, 2018/07/12
- Re: [Qemu-devel] [PATCH 20/20] libqtest: Enable compile-time format string checking,
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH 05/20] qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail(), Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 19/20] migration-test: Clean up string interpolation into QMP, part 3, Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 13/20] tests: Clean up string interpolation around qtest_qmp_device_add(), Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 11/20] tests: Clean up string interpolation into QMP input (simple cases), Markus Armbruster, 2018/07/12
- [Qemu-devel] [PATCH 08/20] test-qobject-input-visitor: Avoid format string ambiguity, Markus Armbruster, 2018/07/12