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

Michal Privoznik mprivozn at redhat.com
Tue Sep 3 16:57:58 UTC 2013


On 03.09.2013 17:35, 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.
> 
> 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(-)

One question though, shouldn't we make VIR_FREE() pass const-ness now?

Michal




More information about the libvir-list mailing list