[libvirt] [PATCH 0/6] Cleanups

First two patches are a result of compiling with -Wunused-macros. They reduce the number of infractions from 111 to 82. The remaining cases are: * unused VIR_FROM_THIS * copies of other headers * in drivers I'm not familiar with enough The next two were found randomly, which lead me to look into virutil.h as well, because just like virsh.c, the util files were split as well. Ján Tomko (6): Remove unused macros Use the DEFAULT_DRIVER_DIR macro Do not include cpu_map.h in libvirtd.c Clean up headers in src/util/virutil.h Remove unused includes from virsh Remove unnecessary includes from virsh.h daemon/libvirtd.c | 2 -- src/conf/network_conf.c | 1 - src/driver.c | 4 ++-- src/locking/lock_daemon.c | 1 - src/locking/lock_driver_lockd.c | 4 ---- src/openvz/openvz_driver.c | 4 ---- src/qemu/qemu_driver.c | 2 -- src/qemu/qemu_monitor_text.c | 3 --- src/test/test_driver.c | 1 - src/uml/uml_driver.c | 3 --- src/util/virutil.c | 4 ---- src/util/virutil.h | 2 -- tests/sockettest.c | 10 ---------- tests/testutils.c | 5 ----- tools/virsh-domain.c | 1 + tools/virsh-network.c | 7 +------ tools/virsh-nodedev.c | 7 +------ tools/virsh-nwfilter.c | 6 ------ tools/virsh-pool.c | 6 ------ tools/virsh-secret.c | 6 ------ tools/virsh-snapshot.c | 1 + tools/virsh.c | 10 ---------- tools/virsh.h | 3 --- 23 files changed, 6 insertions(+), 87 deletions(-) -- 2.0.5

In the order of appearance: * MAX_LISTEN - never used added by 23ad665c (qemud) and addec57 (lock daemon) * NEXT_FREE_CLASS_ID - never used, added by 07d1b6b * virLockError - never used, added by eb8268a4 * OPENVZ_MAX_ARG, CMDBUF_LEN, CMDOP_LEN unused since the removal of ADD_ARG_LIT in d8b31306 * QEMU_NB_PER_CPU_STAT_PARAM - unused since 897808e * QEMU_CMD_PROMPT, QEMU_PASSWD_PROMPT - unused since 1dc10a7 * TEST_MODEL_WORDSIZE - unused since c25c18f7 * TEMPDIR - never used, added by 714bef5 * NSIG - workaround around old headers added by commit 60ed1d2 unused since virExec was moved by commit 02e8691 * DO_TEST_PARSE - never used, added by 9afa006 * DIFF_MSEC, GETTIMEOFDAY - unused since eee6eb6 --- daemon/libvirtd.c | 1 - src/conf/network_conf.c | 1 - src/locking/lock_daemon.c | 1 - src/locking/lock_driver_lockd.c | 4 ---- src/openvz/openvz_driver.c | 4 ---- src/qemu/qemu_driver.c | 2 -- src/qemu/qemu_monitor_text.c | 3 --- src/test/test_driver.c | 1 - src/uml/uml_driver.c | 3 --- src/util/virutil.c | 4 ---- tests/sockettest.c | 10 ---------- tests/testutils.c | 5 ----- 12 files changed, 39 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 2366d63..55acee2 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1097,7 +1097,6 @@ daemonUsage(const char *argv0, bool privileged) } } -#define MAX_LISTEN 5 int main(int argc, char **argv) { virNetServerPtr srv = NULL; char *remote_config_file = NULL; diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index b334b64..f4a9df0 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -47,7 +47,6 @@ #define MAX_BRIDGE_ID 256 #define VIR_FROM_THIS VIR_FROM_NETWORK -#define NEXT_FREE_CLASS_ID 3 /* currently, /sbin/tc implementation allows up to 16 bits for minor class size */ #define CLASS_ID_BITMAP_SIZE (1<<16) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 8cc6979..bb165c0 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1111,7 +1111,6 @@ virLockDaemonUsage(const char *argv0, bool privileged) } } -#define MAX_LISTEN 5 int main(int argc, char **argv) { virNetServerProgramPtr lockProgram = NULL; char *remote_config_file = NULL; diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c index 72a4a0c..3a48a6a 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -38,10 +38,6 @@ VIR_LOG_INIT("locking.lock_driver_lockd"); -#define virLockError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - typedef struct _virLockManagerLockDaemonPrivate virLockManagerLockDaemonPrivate; typedef virLockManagerLockDaemonPrivate *virLockManagerLockDaemonPrivatePtr; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index d29e35b..f9f924f 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -63,10 +63,6 @@ VIR_LOG_INIT("openvz.openvz_driver"); -#define OPENVZ_MAX_ARG 28 -#define CMDBUF_LEN 1488 -#define CMDOP_LEN 288 - #define OPENVZ_NB_MEM_PARAM 3 static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index becf415..9e28bf9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -110,8 +110,6 @@ VIR_LOG_INIT("qemu.qemu_driver"); #define QEMU_NB_NUMA_PARAM 2 -#define QEMU_NB_PER_CPU_STAT_PARAM 2 - #define QEMU_SCHED_MIN_PERIOD 1000LL #define QEMU_SCHED_MAX_PERIOD 1000000LL #define QEMU_SCHED_MIN_QUOTA 1000LL diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 9973a17..f26bc78 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -51,9 +51,6 @@ VIR_LOG_INIT("qemu.qemu_monitor_text"); -#define QEMU_CMD_PROMPT "\n(qemu) " -#define QEMU_PASSWD_PROMPT "Password: " - #define DEBUG_IO 0 /* Return -1 for error, 0 for success */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 07cc032..d49c4b3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -122,7 +122,6 @@ static int defaultConnections; static virMutex defaultLock = VIR_MUTEX_INITIALIZER; #define TEST_MODEL "i686" -#define TEST_MODEL_WORDSIZE 32 #define TEST_EMULATOR "/usr/bin/test-hv" static const virNodeInfo defaultNodeInfo = { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2d59126..6b4f655 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -71,9 +71,6 @@ VIR_LOG_INIT("uml.uml_driver"); -/* For storing short-lived temporary files. */ -#define TEMPDIR LOCALSTATEDIR "/cache/libvirt" - typedef struct _umlDomainObjPrivate umlDomainObjPrivate; typedef umlDomainObjPrivate *umlDomainObjPrivatePtr; struct _umlDomainObjPrivate { diff --git a/src/util/virutil.c b/src/util/virutil.c index 658723b..79cdb7a 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -81,10 +81,6 @@ #include "virstring.h" #include "virutil.h" -#ifndef NSIG -# define NSIG 32 -#endif - verify(sizeof(gid_t) <= sizeof(unsigned int) && sizeof(uid_t) <= sizeof(unsigned int)); diff --git a/tests/sockettest.c b/tests/sockettest.c index fbb5db8..0d348d9 100644 --- a/tests/sockettest.c +++ b/tests/sockettest.c @@ -259,16 +259,6 @@ mymain(void) */ virtTestQuiesceLibvirtErrors(false); -#define DO_TEST_PARSE(addrstr, family, pass) \ - do { \ - virSocketAddr addr; \ - struct testParseData data = { &addr, addrstr, family, pass }; \ - memset(&addr, 0, sizeof(addr)); \ - if (virtTestRun("Test parse " addrstr, \ - testParseHelper, &data) < 0) \ - ret = -1; \ - } while (0) - #define DO_TEST_PARSE_AND_FORMAT(addrstr, family, pass) \ do { \ virSocketAddr addr; \ diff --git a/tests/testutils.c b/tests/testutils.c index f2db4a0..bebb14b 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -62,11 +62,6 @@ VIR_LOG_INIT("tests.testutils"); -#define GETTIMEOFDAY(T) gettimeofday(T, NULL) -#define DIFF_MSEC(T, U) \ - ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ - ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) - #include "virfile.h" static unsigned int testDebug = -1; -- 2.0.5

On Wed, Apr 01, 2015 at 17:32:28 +0200, Ján Tomko wrote:
In the order of appearance:
* MAX_LISTEN - never used added by 23ad665c (qemud) and addec57 (lock daemon)
* NEXT_FREE_CLASS_ID - never used, added by 07d1b6b
* virLockError - never used, added by eb8268a4
* OPENVZ_MAX_ARG, CMDBUF_LEN, CMDOP_LEN unused since the removal of ADD_ARG_LIT in d8b31306
* QEMU_NB_PER_CPU_STAT_PARAM - unused since 897808e
* QEMU_CMD_PROMPT, QEMU_PASSWD_PROMPT - unused since 1dc10a7
* TEST_MODEL_WORDSIZE - unused since c25c18f7
* TEMPDIR - never used, added by 714bef5
* NSIG - workaround around old headers added by commit 60ed1d2 unused since virExec was moved by commit 02e8691
* DO_TEST_PARSE - never used, added by 9afa006
* DIFF_MSEC, GETTIMEOFDAY - unused since eee6eb6
Wow, you bothered with electronic archeology? :)
--- daemon/libvirtd.c | 1 - src/conf/network_conf.c | 1 - src/locking/lock_daemon.c | 1 - src/locking/lock_driver_lockd.c | 4 ---- src/openvz/openvz_driver.c | 4 ---- src/qemu/qemu_driver.c | 2 -- src/qemu/qemu_monitor_text.c | 3 --- src/test/test_driver.c | 1 - src/uml/uml_driver.c | 3 --- src/util/virutil.c | 4 ---- tests/sockettest.c | 10 ---------- tests/testutils.c | 5 ----- 12 files changed, 39 deletions(-)
ACK (after the release) Peter

On Wed, Apr 01, 2015 at 07:30:22PM +0200, Peter Krempa wrote:
On Wed, Apr 01, 2015 at 17:32:28 +0200, Ján Tomko wrote:
In the order of appearance:
* MAX_LISTEN - never used added by 23ad665c (qemud) and addec57 (lock daemon)
* NEXT_FREE_CLASS_ID - never used, added by 07d1b6b
* virLockError - never used, added by eb8268a4
* OPENVZ_MAX_ARG, CMDBUF_LEN, CMDOP_LEN unused since the removal of ADD_ARG_LIT in d8b31306
* QEMU_NB_PER_CPU_STAT_PARAM - unused since 897808e
* QEMU_CMD_PROMPT, QEMU_PASSWD_PROMPT - unused since 1dc10a7
* TEST_MODEL_WORDSIZE - unused since c25c18f7
* TEMPDIR - never used, added by 714bef5
* NSIG - workaround around old headers added by commit 60ed1d2 unused since virExec was moved by commit 02e8691
* DO_TEST_PARSE - never used, added by 9afa006
* DIFF_MSEC, GETTIMEOFDAY - unused since eee6eb6
Wow, you bothered with electronic archeology? :)
--- daemon/libvirtd.c | 1 - src/conf/network_conf.c | 1 - src/locking/lock_daemon.c | 1 - src/locking/lock_driver_lockd.c | 4 ---- src/openvz/openvz_driver.c | 4 ---- src/qemu/qemu_driver.c | 2 -- src/qemu/qemu_monitor_text.c | 3 --- src/test/test_driver.c | 1 - src/uml/uml_driver.c | 3 --- src/util/virutil.c | 4 ---- tests/sockettest.c | 10 ---------- tests/testutils.c | 5 ----- 12 files changed, 39 deletions(-)
ACK (after the release)
Do we have to explictly state that in the freeze? I pushed the series now, thanks for the review. Jan

Unused since commit bc2f42a0. Move it under the WITHOUT_DRIVER_MODULES #ifdef and start using it again. --- src/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/driver.c b/src/driver.c index db03438..2985538 100644 --- a/src/driver.c +++ b/src/driver.c @@ -35,13 +35,13 @@ VIR_LOG_INIT("driver"); -#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver" #ifdef WITH_DRIVER_MODULES /* XXX re-implment this for other OS, or use libtools helper lib ? */ # include <dlfcn.h> +# define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver" void * virDriverLoadModule(const char *name) @@ -57,7 +57,7 @@ virDriverLoadModule(const char *name) "libvirt_driver_", ".so", abs_topbuilddir "/src/.libs", - LIBDIR "/libvirt/connection-driver", + DEFAULT_DRIVER_DIR, "LIBVIRT_DRIVER_DIR"))) return NULL; -- 2.0.5

On Wed, Apr 01, 2015 at 17:32:29 +0200, Ján Tomko wrote:
Unused since commit bc2f42a0.
Move it under the WITHOUT_DRIVER_MODULES #ifdef and start using it again. --- src/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ACK after release. Peter

No longer needed after commit dd47723 --- daemon/libvirtd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 55acee2..107b88d 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -105,7 +105,6 @@ #include "configmake.h" #include "virdbus.h" -#include "cpu/cpu_map.h" VIR_LOG_INIT("daemon.libvirtd"); -- 2.0.5

* "verify.h" from gnulib is included in internal.h * <sys/select.h> is no longer needed added by commit da196338 to use fd_set in virExec prototype --- src/util/virutil.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/virutil.h b/src/util/virutil.h index 25524e2..55a3bd6 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -25,10 +25,8 @@ #ifndef __VIR_UTIL_H__ # define __VIR_UTIL_H__ -# include "verify.h" # include "internal.h" # include <unistd.h> -# include <sys/select.h> # include <sys/types.h> # ifndef MIN -- 2.0.5

On Wed, Apr 01, 2015 at 17:32:31 +0200, Ján Tomko wrote:
* "verify.h" from gnulib is included in internal.h * <sys/select.h> is no longer needed added by commit da196338 to use fd_set in virExec prototype --- src/util/virutil.h | 2 -- 1 file changed, 2 deletions(-)
ACK, Peter

After splitting out most of virsh command, some includes are no longer needed. Some files have the libXML includes despite not needing them. --- tools/virsh-network.c | 6 ------ tools/virsh-nodedev.c | 6 ------ tools/virsh-nwfilter.c | 6 ------ tools/virsh-pool.c | 6 ------ tools/virsh-secret.c | 6 ------ tools/virsh.c | 10 ---------- tools/virsh.h | 1 - 7 files changed, 41 deletions(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 62323c4..39f0266 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -26,16 +26,10 @@ #include <config.h> #include "virsh-network.h" -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #include "internal.h" #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" -#include "virxml.h" #include "conf/network_conf.h" virNetworkPtr diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 46e0045..847e5b0 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -26,16 +26,10 @@ #include <config.h> #include "virsh-nodedev.h" -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #include "internal.h" #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" -#include "virxml.h" #include "conf/node_device_conf.h" /* diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 2a75175..e6bef08 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -26,17 +26,11 @@ #include <config.h> #include "virsh-nwfilter.h" -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #include "internal.h" #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" #include "virutil.h" -#include "virxml.h" virNWFilterPtr vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 485d23d..4865831 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -26,16 +26,10 @@ #include <config.h> #include "virsh-pool.h" -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #include "internal.h" #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" -#include "virxml.h" #include "conf/storage_conf.h" #include "virstring.h" diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index add2c09..5065c6f 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -26,18 +26,12 @@ #include <config.h> #include "virsh-secret.h" -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #include "internal.h" #include "base64.h" #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" #include "virutil.h" -#include "virxml.h" #include "conf/secret_conf.h" static virSecretPtr diff --git a/tools/virsh.c b/tools/virsh.c index 9ecddf3..889a561 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -44,11 +44,6 @@ #include <strings.h> #include <signal.h> -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <libxml/xmlsave.h> - #if WITH_READLINE # include <readline/readline.h> # include <readline/history.h> @@ -56,19 +51,14 @@ #include "internal.h" #include "virerror.h" -#include "base64.h" #include "virbuffer.h" #include "viralloc.h" -#include "virxml.h" #include <libvirt/libvirt-qemu.h> #include <libvirt/libvirt-lxc.h> #include "virfile.h" #include "configmake.h" #include "virthread.h" #include "vircommand.h" -#include "virkeycode.h" -#include "virnetdevbandwidth.h" -#include "virbitmap.h" #include "conf/domain_conf.h" #include "virtypedparam.h" #include "virstring.h" diff --git a/tools/virsh.h b/tools/virsh.h index df2ea7f..3c28454 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -31,7 +31,6 @@ # include <stdarg.h> # include <unistd.h> # include <sys/stat.h> -# include <inttypes.h> # include <termios.h> # include "internal.h" -- 2.0.5

On Wed, Apr 01, 2015 at 17:32:32 +0200, Ján Tomko wrote:
After splitting out most of virsh command, some includes are no longer needed.
Some files have the libXML includes despite not needing them. --- tools/virsh-network.c | 6 ------ tools/virsh-nodedev.c | 6 ------ tools/virsh-nwfilter.c | 6 ------ tools/virsh-pool.c | 6 ------ tools/virsh-secret.c | 6 ------ tools/virsh.c | 10 ---------- tools/virsh.h | 1 - 7 files changed, 41 deletions(-)
ACK, Peter

Include them in the files that need them instead. --- tools/virsh-domain.c | 1 + tools/virsh-network.c | 1 + tools/virsh-nodedev.c | 1 + tools/virsh-snapshot.c | 1 + tools/virsh.h | 2 -- 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9bbb964..eee441f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -47,6 +47,7 @@ #include "virjson.h" #include "virkeycode.h" #include "virmacaddr.h" +#include "virnetdevbandwidth.h" #include "virprocess.h" #include "virstring.h" #include "virsh-console.h" diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 39f0266..09ee11a 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -30,6 +30,7 @@ #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" +#include "virstring.h" #include "conf/network_conf.h" virNetworkPtr diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 847e5b0..0d7315c 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -30,6 +30,7 @@ #include "virbuffer.h" #include "viralloc.h" #include "virfile.h" +#include "virstring.h" #include "conf/node_device_conf.h" /* diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 1bb74a6..459a8a8 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -38,6 +38,7 @@ #include "viralloc.h" #include "virfile.h" #include "virsh-domain.h" +#include "virstring.h" #include "virxml.h" #include "conf/snapshot_conf.h" diff --git a/tools/virsh.h b/tools/virsh.h index 3c28454..e89d315 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -36,8 +36,6 @@ # include "internal.h" # include "virerror.h" # include "virthread.h" -# include "virnetdevbandwidth.h" -# include "virstring.h" # define VSH_MAX_XML_FILE (10*1024*1024) -- 2.0.5

On Wed, Apr 01, 2015 at 17:32:33 +0200, Ján Tomko wrote:
Include them in the files that need them instead. --- tools/virsh-domain.c | 1 + tools/virsh-network.c | 1 + tools/virsh-nodedev.c | 1 + tools/virsh-snapshot.c | 1 + tools/virsh.h | 2 -- 5 files changed, 4 insertions(+), 2 deletions(-)
ACK, Peter
participants (2)
-
Ján Tomko
-
Peter Krempa