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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]