[libvirt] [PATCH 02/22] pci: change stubDriver from const char* to char*

Daniel P. Berrange berrange at redhat.com
Mon Jun 24 14:55:34 UTC 2013


On Mon, Jun 24, 2013 at 05:54:51AM -0400, Laine Stump wrote:
> Previously stubDriver was always set from a string literal, so it was
> okay to use a const char * that wasn't freed when the virPCIDevice was
> freed. This will not be the case in the near future, so it is now a
> char* that is allocated in virPCIDeviceSetStubDriver() and freed
> during virPCIDeviceFree().
> ---
>  src/qemu/qemu_driver.c  |  6 ++++--
>  src/qemu/qemu_hostdev.c | 25 +++++++++++++++++--------
>  src/util/virpci.c       |  8 +++++---
>  src/util/virpci.h       |  4 ++--
>  src/xen/xen_driver.c    |  3 ++-
>  5 files changed, 30 insertions(+), 16 deletions(-)

ACK


It is bad practice to assume you can keep around a copy of any
'const char*' passed in as a parameter, since the const-ness of
the parameter says nothing about whether the caller will free
the parameter value.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list