qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jafar Abdi <cafer.abdi@gmail.com>,
	dgilbert@redhat.com
Subject: [Qemu-devel] [PULL 3/3] test qgraph.c: Fix segs due to out of scope default
Date: Mon,  8 Apr 2019 13:09:20 +0200	[thread overview]
Message-ID: <20190408110920.30119-4-thuth@redhat.com> (raw)
In-Reply-To: <20190408110920.30119-1-thuth@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

The test uses the trick:
   if (!opts) {
     opts = &(QOSGraph...Options) { };
   }

  in a couple of places, however the temporary created
by the &() {}  goes out of scope at the bottom of the if,
and results in a seg or assert when opts-> fields are
used (on fedora 30's gcc 9).

Fixes: fc281c802022cb3a73a5
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190405184037.16799-1-dgilbert@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/libqos/qgraph.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/libqos/qgraph.c b/tests/libqos/qgraph.c
index 122efc1b7b..b149caaaa9 100644
--- a/tests/libqos/qgraph.c
+++ b/tests/libqos/qgraph.c
@@ -77,6 +77,7 @@ static void add_edge(const char *source, const char *dest,
 {
     char *key;
     QOSGraphEdgeList *list = g_hash_table_lookup(edge_table, source);
+    QOSGraphEdgeOptions def_opts = { };
 
     if (!list) {
         list = g_new0(QOSGraphEdgeList, 1);
@@ -85,7 +86,7 @@ static void add_edge(const char *source, const char *dest,
     }
 
     if (!opts) {
-        opts = &(QOSGraphEdgeOptions) { };
+        opts = &def_opts;
     }
 
     QOSGraphEdge *edge = g_new0(QOSGraphEdge, 1);
@@ -590,9 +591,10 @@ void qos_add_test(const char *name, const char *interface,
 {
     QOSGraphNode *node;
     char *test_name = g_strdup_printf("%s-tests/%s", interface, name);;
+    QOSGraphTestOptions def_opts = { };
 
     if (!opts) {
-        opts = &(QOSGraphTestOptions) { };
+        opts = &def_opts;
     }
     node = create_node(test_name, QNODE_TEST);
     node->u.test.function = test_func;
-- 
2.21.0

  parent reply	other threads:[~2019-04-08 11:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 11:09 [Qemu-devel] [PULL 0/3] Fixes for libqos Thomas Huth
2019-04-08 11:09 ` Thomas Huth
2019-04-08 11:09 ` [Qemu-devel] [PULL 1/3] tests/libqos: fix usage of bool in pci-pc.c Thomas Huth
2019-04-08 11:09   ` Thomas Huth
2019-04-08 11:09 ` [Qemu-devel] [PULL 2/3] tests/libqos: fix usage of bool in pci-spapr.c Thomas Huth
2019-04-08 11:09   ` Thomas Huth
2019-04-08 11:09 ` Thomas Huth [this message]
2019-04-08 11:09   ` [Qemu-devel] [PULL 3/3] test qgraph.c: Fix segs due to out of scope default Thomas Huth
2019-04-08 16:50 ` [Qemu-devel] [PULL 0/3] Fixes for libqos Peter Maydell
2019-04-08 16:50   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190408110920.30119-4-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=cafer.abdi@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).