[libvirt] [PATCH 2/2] virnetsockettest: Use a temporary directory in /tmp
Eric Blake
eblake at redhat.com
Wed Nov 2 22:28:54 UTC 2011
On 11/02/2011 04:00 PM, Guido Günther wrote:
>>> + template = strdup("/tmp/libvirt_XXXXXX");
>>
>> No need to malloc() the template. Just do:
>>
>> char template[] = "/tmp/libvirt_XXXXXX";
>
> This was actually the first version I had but it didn't seem to match
> libvirt's style (in the non-const form and I didn't find it in HACKING)
For something short-lived and cleanly scoped, stack allocation of less
than 4k bytes is fine; in fact it is even preferable (more efficient,
fewer failure points). Perhaps most existing uses of mk[ds]temp in
libvirt.git happened to malloc, but that's probably because they are in
situations where the final name must survive the scope of the function
creating the file. I don't know that HACKING has to specifically speak
to this, but I'll review any patch if you want to tweak it to make that
clear.
> so I went for the explicit strdup. New version attached.
ACK to this version.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
More information about the libvir-list
mailing list