]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
test: fix build errors with gcc 4.7.0 and -O0
authorLaine Stump <laine@laine.org>
Thu, 5 Apr 2012 20:31:36 +0000 (16:31 -0400)
committerEric Blake <eblake@redhat.com>
Fri, 6 Apr 2012 04:07:41 +0000 (22:07 -0600)
commit06a1a45cef57eb770069839e98a51bbb6d8eec9d
treec6d9fcf62beb951d93898601a10a155a11e32e7d
parent4eb1c2560d1ab8bae620788d343e9e7b32ddc066
test: fix build errors with gcc 4.7.0 and -O0

When building on Fedora 17 (which uses gcc 4.7.0) with -O0 in CFLAGS,
three of the tests failed to compile.

cputest.c and qemuxml2argvtest.c had non-static structs defined
inside the macro that was being repeatedly invoked. Due to some so-far
unidentified change in gcc, the stack space used by variables defined
inside { } is not recovered/re-used when the block ends, so all these
structs have become additive (this is the same problem worked around
in commit cf57d345b). Fortunately, these two files could be fixed with
a single line addition of "static" to the struct definition in the
macro.

virnettlscontexttest.c was a bit different, though. The problem structs
in the do/while loop of macros had non-constant initializers, so it
took a bit more work and piecemeal initialization instead of member
initialization to get things to be happy.

In an ideal world, none of these changes should be necessary, but not
knowing how long it will be until the gcc regressions are fixed, and
since the code is just as correct after this patch as before, it makes
sense to fix libvirt's build for -O0 while also reporting the gcc
problem.
tests/cputest.c
tests/qemuxml2argvtest.c
tests/virnettlscontexttest.c