[libvirt] [PATCH] tests: Lower stack usage below 4096 bytes
Eric Blake
eblake at redhat.com
Mon Apr 25 16:57:23 UTC 2011
On 04/24/2011 04:26 PM, Matthias Bolte wrote:
> Make virtTestLoadFile allocate the buffer to read the file into.
>
> Fix logic error in virtTestLoadFile, stop reading on the an empty line.
>
> Use virFileReadLimFD in virtTestCaptureProgramOutput.
> ---
> +++ b/tests/commandhelper.c
> @@ -99,8 +99,8 @@ int main(int argc, char **argv) {
> }
>
> fprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
> - char cwd[1024];
> - if (!getcwd(cwd, sizeof(cwd)))
> + char *cwd = NULL;
> + if (!(cwd = getcwd(NULL, 0)))
Ouch. This is not portable to POSIX, and while gnulib can guarantee
that it works, the current gnulib getcwd module is GPL (and relies on
openat, which is a rather heavy-weight replacement!).
I'm going to work on a gnulib module getcwd-lgpl which doesn't fix all
the known bugs in getcwd, but at least guarantees that getcwd(NULL,0)
will malloc insofar as the underlying getcwd is not buggy; we'll need to
import that into libvirt before applying the rest of this patch.
I haven't closely reviewed the rest of this patch yet, but like the
general idea once we have getcwd sorted out.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110425/7863eff7/attachment-0001.sig>
More information about the libvir-list
mailing list