Skip to contentSkip to conversation

libqtest: Avoid inline varargs functions

PATCH In review Peter Maydell 2 participants 3 messages Mar 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libqtest: Avoid inline varargs functions

Older versions of gcc (eg 4.6) can't handle varargs functions declared inline for anything other than completely trivial uses, and complain:

tests/qom-test.c: In function 'qmp': tests/libqtest.h:359:60: sorry,
unimplemented: function 'qmp' can never be inlined because it uses variable argument lists

Avoid this problem by putting the functions into libqtest.c instead of using inline definitions in libqtest.h.

---
This doesn't bite us with the current libqtest code but the enhancements Andreas has in his QOM queue do trigger this gcc 4.6 unimplemented behaviour.

 tests/libqtest.c | 20 ++++++++++++++++++++
 tests/libqtest.h | 20 ++------------------
 2 files changed, 22 insertions(+), 18 deletions(-)
tests/libqtest.c +20 -0
index f587d36..b69dfca 100644
@@ -581,3 +581,23 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
     qtest_sendf(s, "\n");
     qtest_rsp(s, 0);
 }
+
+QDict *qmp(const char *fmt, ...)
+{
+    va_list ap;
+    QDict *response;
+
+    va_start(ap, fmt);
+    response = qtest_qmpv(global_qtest, fmt, ap);
+    va_end(ap);
+    return response;
+}
+
+void qmp_discard_response(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    qtest_qmpv_discard_response(global_qtest, fmt, ap);
+    va_end(ap);
+}
tests/libqtest.h +2 -18
index 9deebdc..8268c09 100644
@@ -356,16 +356,7 @@ static inline void qtest_end(void)
  *
  * Sends a QMP message to QEMU and returns the response.
  */
-static inline QDict *qmp(const char *fmt, ...)
-{
-    va_list ap;
-    QDict *response;
-
-    va_start(ap, fmt);
-    response = qtest_qmpv(global_qtest, fmt, ap);
-    va_end(ap);
-    return response;
-}
+QDict *qmp(const char *fmt, ...);
 
 /**
  * qmp_discard_response:
@@ -373,14 +364,7 @@ static inline QDict *qmp(const char *fmt, ...)
  *
  * Sends a QMP message to QEMU and consumes the response.
  */
-static inline void qmp_discard_response(const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    qtest_qmpv_discard_response(global_qtest, fmt, ap);
-    va_end(ap);
-}
+void qmp_discard_response(const char *fmt, ...);
 
 /**
  * get_irq:
Signature · 1 line
1.9.0
Reviewed-by on v1 1/1
#1 lore raw

Am 13.03.2014 12:31, schrieb Peter Maydell:

Quoted 11 lines

Older versions of gcc (eg 4.6) can't handle varargs functions declared inline for anything other than completely trivial uses, and complain:

tests/qom-test.c: In function 'qmp': tests/libqtest.h:359:60: sorry,
unimplemented: function 'qmp' can never be inlined because it uses variable argument lists

Avoid this problem by putting the functions into libqtest.c instead of using inline definitions in libqtest.h.

Feel free to go ahead with this.

Thanks,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
author Applied
#2 lore raw
Quoted 8 lines · Andreas Färber

Am 13.03.2014 12:31, schrieb Peter Maydell:

Quoted 7 lines

Older versions of gcc (eg 4.6) can't handle varargs functions declared inline for anything other than completely trivial uses, and complain:

tests/qom-test.c: In function 'qmp': tests/libqtest.h:359:60: sorry,
unimplemented: function 'qmp' can never be inlined because it uses variable argument lists

Quoted 8 lines
Quoted 4 lines

Avoid this problem by putting the functions into libqtest.c instead of using inline definitions in libqtest.h.

Feel free to go ahead with this.

Applied to master, thanks. Your pullreq is next in the queue.

thanks
-- PMM