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

[Libvir] [PATCH] lots of warnings removed - libvirt can now compile with -Werror




For a completely clean build you need to also apply the previous patch[1].

Rich.

[1] https://www.redhat.com/archives/libvir-list/2007-March/msg00030.html and see also Mark's reply.

--
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421
 "[Negative numbers] darken the very whole doctrines of the equations
 and make dark of the things which are in their nature excessively
 obvious and simple" (Francis Maseres FRS, mathematician, 1759)
diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
index ce24f59..c7a5294 100644
--- a/include/libvirt/libvirt.h
+++ b/include/libvirt/libvirt.h
@@ -1,4 +1,4 @@
-/*
+/* -*- c -*-
  * libvirt.h:
  * Summary: core interfaces for the libvirt library
  * Description: Provides the interfaces of the libvirt library to handle
@@ -324,7 +324,7 @@ virDomainPtr		virDomainDefineXML	(virConnectPtr conn,
 int			virDomainUndefine	(virDomainPtr domain);
 int                     virConnectNumOfDefinedDomains  (virConnectPtr conn);
 int			virConnectListDefinedDomains (virConnectPtr conn,
-						 const char **names,
+						 char ** const names,
 						 int maxnames);
 int			virDomainCreate		(virDomainPtr domain);
 
@@ -472,7 +472,7 @@ typedef virNetwork *virNetworkPtr;
  */
 int			virConnectNumOfNetworks	(virConnectPtr conn);
 int			virConnectListNetworks	(virConnectPtr conn,
-						 const char **names,
+						 char **const names,
 						 int maxnames);
 
 /*
@@ -480,7 +480,7 @@ int			virConnectListNetworks	(virConnectPtr conn,
  */
 int			virConnectNumOfDefinedNetworks	(virConnectPtr conn);
 int			virConnectListDefinedNetworks	(virConnectPtr conn,
-							 const char **names,
+							 char **const names,
 							 int maxnames);
 
 /*
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index c5461f8..bd8f6a1 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1,4 +1,4 @@
-/*
+/* -*- c -*-
  * libvirt.h:
  * Summary: core interfaces for the libvirt library
  * Description: Provides the interfaces of the libvirt library to handle
@@ -324,7 +324,7 @@ virDomainPtr		virDomainDefineXML	(virConnectPtr conn,
 int			virDomainUndefine	(virDomainPtr domain);
 int                     virConnectNumOfDefinedDomains  (virConnectPtr conn);
 int			virConnectListDefinedDomains (virConnectPtr conn,
-						 const char **names,
+						 char ** const names,
 						 int maxnames);
 int			virDomainCreate		(virDomainPtr domain);
 
@@ -472,7 +472,7 @@ typedef virNetwork *virNetworkPtr;
  */
 int			virConnectNumOfNetworks	(virConnectPtr conn);
 int			virConnectListNetworks	(virConnectPtr conn,
-						 const char **names,
+						 char **const names,
 						 int maxnames);
 
 /*
@@ -480,7 +480,7 @@ int			virConnectListNetworks	(virConnectPtr conn,
  */
 int			virConnectNumOfDefinedNetworks	(virConnectPtr conn);
 int			virConnectListDefinedNetworks	(virConnectPtr conn,
-							 const char **names,
+							 char **const names,
 							 int maxnames);
 
 /*
diff --git a/python/.cvsignore b/python/.cvsignore
index 77c04da..7478275 100644
--- a/python/.cvsignore
+++ b/python/.cvsignore
@@ -4,6 +4,7 @@ Makefile.in
 .libs
 *.lo
 *.la
+*.loT
 libvirt.py
 libvirt-export.c
 libvirtclass.txt
diff --git a/python/Makefile.am b/python/Makefile.am
index d8ffd14..dbb471d 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -33,7 +33,9 @@ all-local: libvirt.py
 python_LTLIBRARIES = libvirtmod.la
 
 libvirtmod_la_SOURCES = libvir.c types.c libvirt-py.c libvirt-py.h
-libvirtmod_la_LIBADD = $(mylibs) 
+libvirtmod_la_LIBADD = $(mylibs)
+# Python header files contain a redundant decl, hence:
+libvirtmod_la_CFLAGS = -Wno-redundant-decls
 
 libvirt.py: $(srcdir)/libvir.py libvirtclass.py
 	cat $(srcdir)/libvir.py libvirtclass.py > libvirt.py
diff --git a/python/libvir.c b/python/libvir.c
index 50a4424..d0e6ee7 100644
--- a/python/libvir.c
+++ b/python/libvir.c
@@ -15,7 +15,7 @@
 #include "libvirt_wrap.h"
 #include "libvirt-py.h"
 
-void initlibvirmod(void);
+extern void initlibvirtmod(void);
 
 PyObject *libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
 PyObject *libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
@@ -266,7 +266,7 @@ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
             Py_INCREF(Py_None);
             return (Py_None);
         }
-        c_retval = virConnectListDefinedDomains(conn, (const char **)names, c_retval);
+        c_retval = virConnectListDefinedDomains(conn, names, c_retval);
         if (c_retval < 0) {
             free(names);
             Py_INCREF(Py_None);
@@ -375,7 +375,7 @@ libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
     return(py_retval);
 }
 
-PyObject *
+static PyObject *
 libvirt_virDomainLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
     PyObject *py_retval;
     virDomainPtr c_retval;
diff --git a/python/libvirt_wrap.h b/python/libvirt_wrap.h
index 8bcfdb3..15e810b 100644
--- a/python/libvirt_wrap.h
+++ b/python/libvirt_wrap.h
@@ -90,7 +90,7 @@ PyObject * libvirt_virDomainPtrWrap(virDomainPtr node);
 
 #define LIBVIRT_ENSURE_THREAD_STATE			\
   LIBVIRT_STMT_START {					\
-  PyGILState_STATE _save;				\
+  PyGILState_STATE _save = PyGILState_UNLOCKED;		\
     if (PyEval_ThreadsInitialized())			\
       _save = PyGILState_Ensure();
 
diff --git a/src/driver.h b/src/driver.h
index b309ce3..bb7d07c 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -119,7 +119,7 @@ typedef char *
 					 int flags);
 typedef int
 	(*virDrvListDefinedDomains)	(virConnectPtr conn,
-					 const char **names,
+					 char ** const names,
 					 int maxnames);
 typedef int
 	(*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
@@ -212,13 +212,13 @@ typedef int
 	(*virDrvNumOfNetworks)		(virConnectPtr conn);
 typedef int
 	(*virDrvListNetworks)		(virConnectPtr conn,
-					 const char **names,
+					 char **const names,
 					 int maxnames);
 typedef int
 	(*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
 typedef int
 	(*virDrvListDefinedNetworks)	(virConnectPtr conn,
-					 const char **names,
+					 char **const names,
 					 int maxnames);
 typedef virNetworkPtr
 	(*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
diff --git a/src/libvirt.c b/src/libvirt.c
index e257d9a..7658a9b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1808,7 +1817,7 @@ virConnectNumOfDefinedDomains(virConnectPtr conn)
  * Returns the number of names provided in the array or -1 in case of error
  */
 int
-virConnectListDefinedDomains(virConnectPtr conn, const char **names,
+virConnectListDefinedDomains(virConnectPtr conn, char ** const names,
                              int maxnames) {
     int ret = -1;
     int i;
@@ -2247,7 +2256,7 @@ virConnectNumOfNetworks(virConnectPtr conn)
  * Returns the number of networks found or -1 in case of error
  */
 int
-virConnectListNetworks(virConnectPtr conn, const char **names, int maxnames)
+virConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
 {
     int ret = -1;
     int i;
@@ -2318,7 +2327,7 @@ virConnectNumOfDefinedNetworks(virConnectPtr conn)
  * Returns the number of names provided in the array or -1 in case of error
  */
 int
-virConnectListDefinedNetworks(virConnectPtr conn, const char **names,
+virConnectListDefinedNetworks(virConnectPtr conn, char **const names,
                               int maxnames) {
     int ret = -1;
     int i;
diff --git a/src/qemu_internal.c b/src/qemu_internal.c
index 0c60582..90b7aa5 100644
--- a/src/qemu_internal.c
+++ b/src/qemu_internal.c
@@ -717,7 +717,7 @@ static int qemuNumOfDefinedDomains(virConnectPtr conn) {
 }
 
 static int qemuListDefinedDomains(virConnectPtr conn,
-                                  const char **names,
+                                  char ** const names,
                                   int maxnames){
     struct qemud_packet req, reply;
     int i, nDomains;
@@ -878,7 +878,7 @@ static int qemuNumOfNetworks(virConnectPtr conn) {
 }
 
 static int qemuListNetworks(virConnectPtr conn,
-                            const char **names,
+                            char **const names,
                             int maxnames) {
     struct qemud_packet req, reply;
     int i, nNetworks;
@@ -916,7 +916,7 @@ static int qemuNumOfDefinedNetworks(virConnectPtr conn) {
 }
 
 static int qemuListDefinedNetworks(virConnectPtr conn,
-                                   const char **names,
+                                   char **const names,
                                    int maxnames) {
     struct qemud_packet req, reply;
     int i, nNetworks;
diff --git a/src/test.c b/src/test.c
index c9898cf..39eeab6 100644
--- a/src/test.c
+++ b/src/test.c
@@ -76,7 +76,7 @@ char * testDomainDumpXML(virDomainPtr domain, int flags);
 
 int testNumOfDefinedDomains(virConnectPtr conn);
 int testListDefinedDomains(virConnectPtr conn,
-                           const char **names,
+                           char ** const names,
                            int maxnames);
 
 virDomainPtr testDomainDefineXML(virConnectPtr conn,
@@ -1289,7 +1289,7 @@ int testNumOfDefinedDomains(virConnectPtr conn) {
 }
 
 int testListDefinedDomains(virConnectPtr conn,
-                           const char **names,
+                           char ** const names,
                            int maxnames) {
     testCon *con = &node->connections[conn->handle];
     int n = 0, i;
diff --git a/src/virsh.c b/src/virsh.c
index f996902..fa84ced 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -471,7 +471,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
     int all = vshCommandOptBool(cmd, "all");
     int active = !inactive || all ? 1 : 0;
     int *ids = NULL, maxid = 0, i;
-    const char **names = NULL;
+    char **names = NULL;
     int maxname = 0;
     inactive |= all;
 
@@ -1925,7 +1925,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
     int all = vshCommandOptBool(cmd, "all");
     int active = !inactive || all ? 1 : 0;
     int maxactive = 0, maxinactive = 0, i;
-    const char **activeNames = NULL, **inactiveNames = NULL;
+    char **activeNames = NULL, **inactiveNames = NULL;
     inactive |= all;
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
@@ -1938,15 +1938,15 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
             return FALSE;
         }
         if (maxactive) {
-            activeNames = vshMalloc(ctl, sizeof(int) * maxactive);
+            activeNames = vshMalloc(ctl, sizeof (char *) * maxactive);
 
-            if ((maxactive = virConnectListNetworks(ctl->conn, &activeNames[0], maxactive)) < 0) {
+            if ((maxactive = virConnectListNetworks(ctl->conn, activeNames, maxactive)) < 0) {
                 vshError(ctl, FALSE, _("Failed to list active networks"));
                 free(activeNames);
                 return FALSE;
             }
 
-            qsort(&activeNames[0], maxactive, sizeof(int), namesorter);
+            qsort(activeNames, maxactive, sizeof (char *), namesorter);
         }
     }
     if (inactive) {
diff --git a/src/xen_internal.c b/src/xen_internal.c
index a53ea89..54571d9 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -1127,7 +1127,7 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt,
  * Initialize the hypervisor layer. Try to detect the kind of interface
  * used i.e. pre or post changeset 10277
  */
-int
+static int
 xenHypervisorInit(void)
 {
     int fd, ret, cmd;
diff --git a/src/xend_internal.c b/src/xend_internal.c
index ec38c49..b3fd959 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -41,7 +41,7 @@
 static const char * xenDaemonGetType(virConnectPtr conn);
 static int xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids);
 static int xenDaemonNumOfDomains(virConnectPtr conn);
-static int xenDaemonListDefinedDomains(virConnectPtr conn, const char **names, int maxnames);
+static int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames);
 static int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
 static virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
 static virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn,
@@ -1038,7 +1038,8 @@ xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
                      _("domain information incorrect domid not numeric"));
         ret = -1;
     } else if (uuid != NULL) {
-        char **ptr = (char **) &uuid;
+        char *uuid_c = (char *) uuid;
+        char **ptr = &uuid_c;
 
         if (sexpr_uuid(ptr, root, "domain/uuid") == NULL) {
             virXendError(xend, VIR_ERR_INTERNAL_ERROR,
@@ -1108,6 +1109,7 @@ error:
 }
 
 
+#ifndef PROXY
 static int
 xend_detect_config_version(virConnectPtr conn) {
     struct sexpr *root;
@@ -1135,7 +1137,6 @@ xend_detect_config_version(virConnectPtr conn) {
     return conn->xendConfigVersion;
 }
 
-#ifndef PROXY
 /**
  * xend_node_shutdown:
  * @xend: A xend instance
@@ -3054,7 +3055,7 @@ error:
     return(ret);
 }
 
-int xenDaemonListDefinedDomains(virConnectPtr conn, const char **names, int maxnames) {
+int xenDaemonListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames) {
     struct sexpr *root = NULL;
     int ret = -1;
     struct sexpr *_for_i, *node;
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 066d86d..09f5acf 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -2182,7 +2182,7 @@ struct xenXMListIteratorContext {
     virConnectPtr conn;
     int max;
     int count;
-    const char **names;
+    char ** names;
 };
 
 static void xenXMListIterator(const void *payload ATTRIBUTE_UNUSED, const char *name, const void *data) {
@@ -2206,7 +2206,7 @@ static void xenXMListIterator(const void *payload ATTRIBUTE_UNUSED, const char *
  * List all defined domains, filtered to remove any which
  * are currently running
  */
-int xenXMListDefinedDomains(virConnectPtr conn, const char **names, int maxnames) {
+int xenXMListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames) {
     struct xenXMListIteratorContext ctx;
 
     if (!VIR_IS_CONNECT(conn)) {
diff --git a/src/xm_internal.h b/src/xm_internal.h
index d86ff29..f28cd66 100644
--- a/src/xm_internal.h
+++ b/src/xm_internal.h
@@ -46,7 +46,7 @@ virDomainPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname);
 virDomainPtr xenXMDomainLookupByUUID(virConnectPtr conn,
 				     const unsigned char *uuid);
 
-int xenXMListDefinedDomains(virConnectPtr conn, const char **names, int maxnames);
+int xenXMListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames);
 int xenXMNumOfDefinedDomains(virConnectPtr conn);
 
 int xenXMDomainCreate(virDomainPtr domain);
diff --git a/tests/reconnect.c b/tests/reconnect.c
index 41466c2..6a6a1d2 100644
--- a/tests/reconnect.c
+++ b/tests/reconnect.c
@@ -2,8 +2,10 @@
 #include <stdlib.h>
 #include <libvirt/libvirt.h>
 #include <libvirt/virterror.h>
+#include "internal.h"
 
-static void errorHandler(void *userData, virErrorPtr error) {
+static void errorHandler(void *userData ATTRIBUTE_UNUSED,
+			 virErrorPtr error ATTRIBUTE_UNUSED) {
 }
 
 int main(void) {

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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