• L
    test: fix build errors with gcc 4.7.0 and -O0 · 06a1a45c
    Laine Stump 提交于
    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 cf57d345). 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.
    06a1a45c
cputest.c 18.7 KB