[libvirt] [PATCHv2 2/3] qemu: simplify list cleanup

Michal Privoznik mprivozn at redhat.com
Wed Sep 4 12:14:02 UTC 2013


On 28.08.2013 23:01, Eric Blake wrote:
> No need to open code now that we have a nice function.
> 
> Interestingly, our virStringFreeList function is typed correctly
> (a malloc'd list of malloc'd strings is NOT const, whether at the
> point where it is created, or at the point where it is cleand up),
> so using it with a 'const char **' argument would require a cast
> to keep the compiler.  I chose instead to remove const from code
> even where we don't modify the argument, just to avoid the need
> to cast.
> 
> * src/qemu/qemu_command.h (qemuParseCommandLine): Drop declaration.
> * src/qemu/qemu_command.c (qemuParseProcFileStrings)
> (qemuStringToArgvEnv): Don't force malloc'd result to be const.
> (qemuParseCommandLinePid, qemuParseCommandLineString): Simplify
> cleanup.
> (qemuParseCommandLine, qemuFindEnv): Drop const-correctness to
> avoid the need to cast in callers.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
> 
> v2: fix compilation, and extend the cleanup
> 
>  src/qemu/qemu_command.c | 72 +++++++++++++++++++------------------------------
>  src/qemu/qemu_command.h |  7 -----
>  2 files changed, 27 insertions(+), 52 deletions(-)

ACK

Michal




More information about the libvir-list mailing list