提交 607806f8 编写于 作者: M Michal Privoznik

Fix const correctness

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: NMichal Privoznik <mprivozn@redhat.com>
上级 70120e2f
...@@ -243,7 +243,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged, ...@@ -243,7 +243,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
{ {
virNetClientPtr client = NULL; virNetClientPtr client = NULL;
char *lockdpath; char *lockdpath;
const char *daemonPath = NULL; char *daemonPath = NULL;
*prog = NULL; *prog = NULL;
......
...@@ -2652,7 +2652,7 @@ static int ...@@ -2652,7 +2652,7 @@ static int
virQEMUCapsSaveCache(virQEMUCapsPtr qemuCaps, const char *filename) virQEMUCapsSaveCache(virQEMUCapsPtr qemuCaps, const char *filename)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *xml = NULL; char *xml = NULL;
int ret = -1; int ret = -1;
size_t i; size_t i;
......
...@@ -582,7 +582,7 @@ doRemoteOpen(virConnectPtr conn, ...@@ -582,7 +582,7 @@ doRemoteOpen(virConnectPtr conn,
trans_tcp, trans_tcp,
} transport; } transport;
#ifndef WIN32 #ifndef WIN32
const char *daemonPath = NULL; char *daemonPath = NULL;
#endif #endif
/* We handle *ALL* URIs here. The caller has rejected any /* We handle *ALL* URIs here. The caller has rejected any
......
...@@ -49,6 +49,7 @@ xenSessionFree(xen_session *session) ...@@ -49,6 +49,7 @@ xenSessionFree(xen_session *session)
VIR_FREE(session->error_description[i]); VIR_FREE(session->error_description[i]);
VIR_FREE(session->error_description); VIR_FREE(session->error_description);
} }
/* The session_id member is type of 'const char *'. Sigh. */
VIR_FREE(session->session_id); VIR_FREE(session->session_id);
VIR_FREE(session); VIR_FREE(session);
} }
......
...@@ -10349,8 +10349,8 @@ vshPrepareDiskXML(xmlNodePtr disk_node, ...@@ -10349,8 +10349,8 @@ vshPrepareDiskXML(xmlNodePtr disk_node,
int type) int type)
{ {
xmlNodePtr cur = NULL; xmlNodePtr cur = NULL;
const char *disk_type = NULL; char *disk_type = NULL;
const char *device_type = NULL; char *device_type = NULL;
xmlNodePtr new_node = NULL; xmlNodePtr new_node = NULL;
char *ret = NULL; char *ret = NULL;
......
...@@ -105,7 +105,7 @@ dissect_xdr_string(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, ...@@ -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) format_xdr_bytes(guint8 *bytes, guint32 length)
{ {
gchar *buf; gchar *buf;
...@@ -206,7 +206,7 @@ dissect_xdr_iterable(tvbuff_t *tvb, proto_item *ti, XDR *xdrs, gint ett, int rhf ...@@ -206,7 +206,7 @@ dissect_xdr_iterable(tvbuff_t *tvb, proto_item *ti, XDR *xdrs, gint ett, int rhf
static gboolean static gboolean
dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett, 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; goffset start;
proto_item *ti; proto_item *ti;
...@@ -219,7 +219,7 @@ dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett, ...@@ -219,7 +219,7 @@ dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
static gboolean static gboolean
dissect_xdr_array(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett, 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; goffset start;
proto_item *ti; proto_item *ti;
......
...@@ -105,9 +105,9 @@ static gboolean dissect_xdr_bytes(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, in ...@@ -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, static gboolean dissect_xdr_pointer(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
vir_xdr_dissector_t dp); vir_xdr_dissector_t dp);
static gboolean dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett, 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, 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" # include "libvirt/protocol.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册