]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix const correctness
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Jul 2014 11:36:00 +0000 (13:36 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 16 Jul 2014 10:07:24 +0000 (12:07 +0200)
In many places we define a variable as a 'const char *' when in fact
we modify it just a few lines below. Or even free it. We should not do
that.

There's one exception though, in xenSessionFree() xenapi_utils.c. We
are freeing the xen_session structure which is defined in
xen/api/xen_common.h public header. The structure contains session_id
which is type of 'const char *' when in fact it should have been just
'char *'. So I'm leaving this unmodified, just noticing the fact in
comment.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/locking/lock_driver_lockd.c
src/qemu/qemu_capabilities.c
src/remote/remote_driver.c
src/xenapi/xenapi_utils.c
tools/virsh-domain.c
tools/wireshark/src/packet-libvirt.c
tools/wireshark/src/packet-libvirt.h

index 1ca777284e97d44c547df9bad6d1f7dd1d09d799..367d0ceb1c0e25659243b176e6d33138188bd2c6 100644 (file)
@@ -243,7 +243,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
 {
     virNetClientPtr client = NULL;
     char *lockdpath;
-    const char *daemonPath = NULL;
+    char *daemonPath = NULL;
 
     *prog = NULL;
 
index 37e0588fc94e0a7f8738a50c309cc4640523ab82..8271e28141c6c9e2b6efb72b1990403ba4691910 100644 (file)
@@ -2652,7 +2652,7 @@ static int
 virQEMUCapsSaveCache(virQEMUCapsPtr qemuCaps, const char *filename)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    const char *xml = NULL;
+    char *xml = NULL;
     int ret = -1;
     size_t i;
 
index 9d8120f80313937d57a85c042cc743c638433e98..9a1d78fc4f10a4a768d6fdbff5c7a5a4a535500c 100644 (file)
@@ -582,7 +582,7 @@ doRemoteOpen(virConnectPtr conn,
         trans_tcp,
     } transport;
 #ifndef WIN32
-    const char *daemonPath = NULL;
+    char *daemonPath = NULL;
 #endif
 
     /* We handle *ALL* URIs here. The caller has rejected any
index 8b28914d4be23a5ed0f2c61057f575a78c5420b6..a80d1365199896949b3a4df7e4a8bd8960f943d9 100644 (file)
@@ -49,6 +49,7 @@ xenSessionFree(xen_session *session)
             VIR_FREE(session->error_description[i]);
         VIR_FREE(session->error_description);
     }
+    /* The session_id member is type of 'const char *'. Sigh. */
     VIR_FREE(session->session_id);
     VIR_FREE(session);
 }
index 5a17affccba510b733db15f60dc84aa4cc0f6175..ba472586226c9172fa954dcea1714780ea4c788b 100644 (file)
@@ -10349,8 +10349,8 @@ vshPrepareDiskXML(xmlNodePtr disk_node,
                   int type)
 {
     xmlNodePtr cur = NULL;
-    const char *disk_type = NULL;
-    const char *device_type = NULL;
+    char *disk_type = NULL;
+    char *device_type = NULL;
     xmlNodePtr new_node = NULL;
     char *ret = NULL;
 
index 0fe5f036d136be8685dd3e9d504dbd1c5f894bcb..5c3c369b08559e3eaeb70169cb1b238c71854c0f 100644 (file)
@@ -105,7 +105,7 @@ dissect_xdr_string(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
     }
 }
 
-static gchar *
+static const gchar *
 format_xdr_bytes(guint8 *bytes, guint32 length)
 {
     gchar *buf;
@@ -206,7 +206,7 @@ dissect_xdr_iterable(tvbuff_t *tvb, proto_item *ti, XDR *xdrs, gint ett, int rhf
 
 static gboolean
 dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
-                   int rhf, gchar *rtype, guint32 size, vir_xdr_dissector_t dissect)
+                   int rhf, const gchar *rtype, guint32 size, vir_xdr_dissector_t dissect)
 {
     goffset start;
     proto_item *ti;
@@ -219,7 +219,7 @@ dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
 
 static gboolean
 dissect_xdr_array(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
-                  int rhf, gchar *rtype, guint32 maxlen, vir_xdr_dissector_t dissect)
+                  int rhf, const gchar *rtype, guint32 maxlen, vir_xdr_dissector_t dissect)
 {
     goffset start;
     proto_item *ti;
index af54407f294df07dfb8b61eadb825e48b353fa09..5f99fdfaedddcea64dd13d566b3ccce4f203faad 100644 (file)
@@ -105,9 +105,9 @@ static gboolean dissect_xdr_bytes(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, in
 static gboolean dissect_xdr_pointer(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
                                     vir_xdr_dissector_t dp);
 static gboolean dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
-                                   int rhf, gchar *rtype, guint32 size, vir_xdr_dissector_t dp);
+                                   int rhf, const gchar *rtype, guint32 size, vir_xdr_dissector_t dp);
 static gboolean dissect_xdr_array(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
-                                  int rhf, gchar *rtype, guint32 maxlen, vir_xdr_dissector_t dp);
+                                  int rhf, const gchar *rtype, guint32 maxlen, vir_xdr_dissector_t dp);
 
 # include "libvirt/protocol.h"