diff mbox

[kvm-unit-tests,2/6] libcflat: add format checking to report()

Message ID 20170517201405.19867-3-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář May 17, 2017, 8:14 p.m. UTC
report() is a wrapper for printf(), but the compiler was not aware.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 lib/libcflat.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Thomas Huth May 18, 2017, 2:38 a.m. UTC | #1
On 17.05.2017 22:14, Radim Krčmář wrote:
> report() is a wrapper for printf(), but the compiler was not aware.
> 
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  lib/libcflat.h | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index b1ea5e607033..a5c42903b11f 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -96,14 +96,20 @@ extern int vsnprintf(char *buf, int size, const char *fmt, va_list va)
>  extern int vprintf(const char *fmt, va_list va)
>  					__attribute__((format(printf, 1, 0)));
>  
> -void report_prefix_pushf(const char *prefix_fmt, ...);
> +void report_prefix_pushf(const char *prefix_fmt, ...)
> +					__attribute__((format(printf, 1, 2)));
>  extern void report_prefix_push(const char *prefix);
>  extern void report_prefix_pop(void);
> -extern void report(const char *msg_fmt, bool pass, ...);
> -extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
> -extern void report_abort(const char *msg_fmt, ...);
> -extern void report_skip(const char *msg_fmt, ...);
> -extern void report_info(const char *msg_fmt, ...);
> +extern void report(const char *msg_fmt, bool pass, ...)
> +					__attribute__((format(printf, 1, 3)));
> +extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...)
> +					__attribute__((format(printf, 1, 4)));
> +extern void report_abort(const char *msg_fmt, ...)
> +					__attribute__((format(printf, 1, 2)));
> +extern void report_skip(const char *msg_fmt, ...)
> +					__attribute__((format(printf, 1, 2)));
> +extern void report_info(const char *msg_fmt, ...)
> +					__attribute__((format(printf, 1, 2)));
>  extern void report_pass(void);
>  extern int report_summary(void);

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index b1ea5e607033..a5c42903b11f 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -96,14 +96,20 @@  extern int vsnprintf(char *buf, int size, const char *fmt, va_list va)
 extern int vprintf(const char *fmt, va_list va)
 					__attribute__((format(printf, 1, 0)));
 
-void report_prefix_pushf(const char *prefix_fmt, ...);
+void report_prefix_pushf(const char *prefix_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
 extern void report_prefix_push(const char *prefix);
 extern void report_prefix_pop(void);
-extern void report(const char *msg_fmt, bool pass, ...);
-extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
-extern void report_abort(const char *msg_fmt, ...);
-extern void report_skip(const char *msg_fmt, ...);
-extern void report_info(const char *msg_fmt, ...);
+extern void report(const char *msg_fmt, bool pass, ...)
+					__attribute__((format(printf, 1, 3)));
+extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...)
+					__attribute__((format(printf, 1, 4)));
+extern void report_abort(const char *msg_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
+extern void report_skip(const char *msg_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
+extern void report_info(const char *msg_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
 extern void report_pass(void);
 extern int report_summary(void);