[libvirt] [PATCH 2/5] tests: refactor virstoragetest for less stack space

Peter Krempa pkrempa at redhat.com
Fri Apr 4 08:54:35 UTC 2014


On 04/04/14 06:32, Eric Blake wrote:
> I'm about to add fields to virStorageFileMetadata, which means
> also adding fields to the testFileData struct in virstoragetest.
> Alas, adding even one pointer on an x86_64 machine gave me a
> dreaded compiler error:
> 
> virstoragetest.c:712:1: error: the frame size of 4208 bytes is larger than 4096 bytes [-Werror=frame-larger-than=]
> 
> After some experimentation, I realized that each test was creating
> yet another testChainData (which contains testFileData) on the stack;
> forcing the reuse of one of these structures instead of creating a
> fresh one each time drastically reduces the size requirements.  While
> at it, I also got rid of a lot of intermediate structs, with some
> macro magic that lets me directly build up the destination chains
> inline.

Unfortunately it's not completely trivial to understand what's happening
on the first glance.

> 
> * tests/virstoragetest.c (mymain): Rewrite TEST_ONE_CHAIN to
> reuse the same struct for each test, and to take the data
> inline rather than via intermediate variables.
> (testChainData): Use bounded array of pointers instead of
> unlimited array of struct.
> (testStorageChain): Reflect struct change.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  tests/virstoragetest.c | 167 ++++++++++++++++++++++++-------------------------
>  1 file changed, 81 insertions(+), 86 deletions(-)
> 

As it's test code: ACK

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140404/221b45eb/attachment-0001.sig>


More information about the libvir-list mailing list