[libvirt] [PATCH] Stop free'ing 'const char *' strings

Eric Blake eblake at redhat.com
Tue Sep 3 17:43:13 UTC 2013


On 09/03/2013 09:35 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> The VIR_FREE() macro will cast away any const-ness. This masked a
> number of places where we passed a 'const char *' string to
> VIR_FREE. Fortunately in all of these cases, the variable was not
> in fact const data, but a heap allocated string. Fix all the
> variable declarations to reflect this.

I already have a patch pending review for a subset of this issue:
https://www.redhat.com/archives/libvir-list/2013-August/msg01474.html

I'm very much a fan of the idea.

> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/conf/domain_conf.c                 | 30 +++++++++++++++---------------
>  src/conf/netdev_vlan_conf.c            |  4 ++--
>  src/conf/nwfilter_conf.c               |  3 ++-
>  src/node_device/node_device_udev.c     |  2 +-
>  src/nwfilter/nwfilter_gentech_driver.c |  2 +-
>  src/qemu/qemu_command.c                | 33 +++++++++++++++++++--------------
>  src/qemu/qemu_domain.c                 |  2 +-
>  src/qemu/qemu_driver.c                 |  4 ++--
>  src/rpc/virnetsshsession.c             | 34 +++++++++++++++++++++-------------
>  src/storage/storage_backend.c          |  2 +-
>  src/storage/storage_driver.c           |  2 +-
>  src/util/vircommand.c                  |  9 ++++-----
>  src/util/virlog.c                      |  4 ++--
>  tools/virsh-domain.c                   | 19 ++++++++++---------
>  14 files changed, 82 insertions(+), 68 deletions(-)

Where's the actual patch to VIR_FREE to drop the const cast, and let the
compiler enforce things so that we don't reintroduce the problem in the
future?

Other than that (which could be done as a followup patch), I agree with
Michal's ack.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130903/f5165c3e/attachment-0001.sig>


More information about the libvir-list mailing list