aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2019-04-05 19:40:37 +0100
committerThomas Huth <thuth@redhat.com>2019-04-08 12:38:07 +0200
commitc19f2b711e15dac4c2cdbace2f8fb3a45fbed0d2 (patch)
treef3c51851c9cf1f0b8d231410aeaec4bc929e7b9b /tests/libqos
parentc098aac7dcc6f7c359be15c88ee26a1da8735f3f (diff)
test qgraph.c: Fix segs due to out of scope default
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>
Diffstat (limited to 'tests/libqos')
-rw-r--r--tests/libqos/qgraph.c6
1 files 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;