kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] lib: use an argument which doesn't require default argument promotion
@ 2019-09-09 23:11 Bill Wendling
  2019-09-10 16:43 ` Jim Mattson
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Bill Wendling @ 2019-09-09 23:11 UTC (permalink / raw)
  To: kvm

Clang warns that passing an object that undergoes default argument
promotion to "va_start" is undefined behavior:

lib/report.c:106:15: error: passing an object that undergoes default
argument promotion to 'va_start' has undefined behavior
[-Werror,-Wvarargs]
        va_start(va, pass);

Using an "unsigned" type removes the need for argument promotion.

Signed-off-by: Bill Wendling <morbo@google.com>
---
 lib/libcflat.h | 4 ++--
 lib/report.c   | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index b94d0ac..b6635d9 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -99,9 +99,9 @@ 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(const char *msg_fmt, unsigned pass, ...)
  __attribute__((format(printf, 1, 3)));
-extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...)
+extern void report_xfail(const char *msg_fmt, bool xfail, unsigned pass, ...)
  __attribute__((format(printf, 1, 4)));
 extern void report_abort(const char *msg_fmt, ...)
  __attribute__((format(printf, 1, 2)))
diff --git a/lib/report.c b/lib/report.c
index ca9b4fd..7d259f6 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -81,7 +81,7 @@ void report_prefix_pop(void)
 }

 static void va_report(const char *msg_fmt,
- bool pass, bool xfail, bool skip, va_list va)
+ unsigned pass, bool xfail, bool skip, va_list va)
 {
  const char *prefix = skip ? "SKIP"
    : xfail ? (pass ? "XPASS" : "XFAIL")
@@ -104,7 +104,7 @@ static void va_report(const char *msg_fmt,
  spin_unlock(&lock);
 }

-void report(const char *msg_fmt, bool pass, ...)
+void report(const char *msg_fmt, unsigned pass, ...)
 {
  va_list va;
  va_start(va, pass);
@@ -112,7 +112,7 @@ void report(const char *msg_fmt, bool pass, ...)
  va_end(va);
 }

-void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...)
+void report_xfail(const char *msg_fmt, bool xfail, unsigned pass, ...)
 {
  va_list va;
  va_start(va, pass);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-10-17 12:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 23:11 [kvm-unit-tests PATCH] lib: use an argument which doesn't require default argument promotion Bill Wendling
2019-09-10 16:43 ` Jim Mattson
2019-09-30 21:59   ` Bill Wendling
2019-10-09 10:13 ` Paolo Bonzini
2019-10-11 14:19 ` David Hildenbrand
2019-10-11 16:24   ` Thomas Huth
2019-10-11 16:36     ` Thomas Huth
2019-10-11 18:36       ` Bill Wendling
2019-10-14  7:57         ` Thomas Huth
2019-10-14  8:12           ` David Hildenbrand
2019-10-14  8:14           ` Bill Wendling
2019-10-14  9:32             ` Thomas Huth
2019-10-14 11:04           ` Paolo Bonzini
2019-10-17 12:32             ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).