[PATCH] Drop unused function declarations

Michal Privoznik posted 1 patch 1 week, 1 day ago
src/ch/ch_monitor.h           |  4 ----
src/conf/device_conf.h        |  1 -
src/conf/virinterfaceobj.h    |  3 ---
src/conf/virstorageobj.h      |  3 ---
src/libxl/libxl_domain.h      |  3 ---
src/logging/log_handler.h     |  2 --
src/lxc/lxc_cgroup.h          |  1 -
src/lxc/lxc_hostdev.h         |  6 ------
src/lxc/lxc_monitor.h         |  3 ---
src/lxc/lxc_process.h         |  9 ---------
src/qemu/qemu_command.h       |  3 ---
src/qemu/qemu_domain.h        | 12 ------------
src/qemu/qemu_monitor.h       |  4 ----
src/qemu/qemu_monitor_json.h  | 29 -----------------------------
src/qemu/qemu_process.h       |  3 ---
src/rpc/virnetlibsshsession.h |  1 -
src/rpc/virnetserverclient.h  |  2 --
src/util/virmdev.h            |  3 ---
src/util/virnetdev.h          | 10 ----------
src/vz/vz_utils.h             |  8 --------
tests/testutilsqemu.h         |  3 ---
21 files changed, 113 deletions(-)
[PATCH] Drop unused function declarations
Posted by Michal Privoznik 1 week, 1 day ago
When moving function and/or renaming them sometimes corresponding
change to corresponding header file is not done. This leaves us
with functions that are declared in header files, but nowhere
implemented. Drop such declarations.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

These were identified by a bash oneliner which basically tried to list
every "function" in every header file (function was matched as '\w\+(')
and for every function from the list, git grep was done to see if it
lives in a .c file.

It's nowhere exhaustive or perfect, but if found at least something.

 src/ch/ch_monitor.h           |  4 ----
 src/conf/device_conf.h        |  1 -
 src/conf/virinterfaceobj.h    |  3 ---
 src/conf/virstorageobj.h      |  3 ---
 src/libxl/libxl_domain.h      |  3 ---
 src/logging/log_handler.h     |  2 --
 src/lxc/lxc_cgroup.h          |  1 -
 src/lxc/lxc_hostdev.h         |  6 ------
 src/lxc/lxc_monitor.h         |  3 ---
 src/lxc/lxc_process.h         |  9 ---------
 src/qemu/qemu_command.h       |  3 ---
 src/qemu/qemu_domain.h        | 12 ------------
 src/qemu/qemu_monitor.h       |  4 ----
 src/qemu/qemu_monitor_json.h  | 29 -----------------------------
 src/qemu/qemu_process.h       |  3 ---
 src/rpc/virnetlibsshsession.h |  1 -
 src/rpc/virnetserverclient.h  |  2 --
 src/util/virmdev.h            |  3 ---
 src/util/virnetdev.h          | 10 ----------
 src/vz/vz_utils.h             |  8 --------
 tests/testutilsqemu.h         |  3 ---
 21 files changed, 113 deletions(-)

diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h
index b35f5ea027..9ec58e5b20 100644
--- a/src/ch/ch_monitor.h
+++ b/src/ch/ch_monitor.h
@@ -118,10 +118,6 @@ int virCHMonitorSaveVM(virCHMonitor *mon,
                        const char *to);
 int virCHMonitorGetInfo(virCHMonitor *mon, virJSONValue **info);
 
-void virCHMonitorCPUInfoFree(virCHMonitorCPUInfo *cpus);
-int virCHMonitorGetCPUInfo(virCHMonitor *mon,
-                           virCHMonitorCPUInfo **vcpus,
-                           size_t maxvcpus);
 size_t virCHMonitorGetThreadInfo(virCHMonitor *mon, bool refresh,
                                  virCHMonitorThreadInfo **threads);
 int virCHMonitorGetIOThreads(virCHMonitor *mon,
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 2d674ecd85..2d97410f6e 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -193,7 +193,6 @@ int virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node,
 int virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf,
                                         const virDeviceHostdevPCIDriverInfo *driver);
 
-void virDeviceHostdevPCIDriverInfoPostParse(virDeviceHostdevPCIDriverInfo *driver);
 void virDeviceHostdevPCIDriverInfoClear(virDeviceHostdevPCIDriverInfo *driver);
 
 void virDomainDeviceInfoClear(virDomainDeviceInfo *info);
diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h
index 5927484167..c59dac28d3 100644
--- a/src/conf/virinterfaceobj.h
+++ b/src/conf/virinterfaceobj.h
@@ -51,9 +51,6 @@ virInterfaceObj *
 virInterfaceObjListFindByName(virInterfaceObjList *interfaces,
                               const char *name);
 
-void
-virInterfaceObjFree(virInterfaceObj *obj);
-
 virInterfaceObjList *
 virInterfaceObjListClone(virInterfaceObjList *interfaces);
 
diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h
index d9dae9ceb9..e1eabfdb3a 100644
--- a/src/conf/virstorageobj.h
+++ b/src/conf/virstorageobj.h
@@ -229,9 +229,6 @@ virStoragePoolObjGetNames(virStoragePoolObjList *pools,
                           char **const names,
                           int maxnames);
 
-void
-virStoragePoolObjFree(virStoragePoolObj *obj);
-
 typedef void
 (*virStoragePoolObjListIterator)(virStoragePoolObj *obj,
                                  const void *opaque);
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 94b693e477..a35d121323 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -46,9 +46,6 @@ extern virDomainDefParserConfig libxlDomainDefParserConfig;
 extern virXMLNamespace libxlDriverDomainXMLNamespace;
 extern const struct libxl_event_hooks ev_hooks;
 
-int
-libxlDomainObjPrivateInitCtx(virDomainObj *vm);
-
 int
 libxlDomainJobGetTimeElapsed(virDomainJobObj *job,
                              unsigned long long *timeElapsed);
diff --git a/src/logging/log_handler.h b/src/logging/log_handler.h
index 97dad27eda..38c300289e 100644
--- a/src/logging/log_handler.h
+++ b/src/logging/log_handler.h
@@ -67,8 +67,6 @@ virLogHandler *virLogHandlerNewPostExecRestart(virJSONValue *child,
                                                virLogHandlerShutdownInhibitor inhibitor,
                                                void *opaque);
 
-void virLogHandlerFree(virLogHandler *handler);
-
 int virLogHandlerDomainOpenLogFile(virLogHandler *handler,
                                    const char *driver,
                                    const unsigned char *domuuid,
diff --git a/src/lxc/lxc_cgroup.h b/src/lxc/lxc_cgroup.h
index 64d0c51175..83f342c08c 100644
--- a/src/lxc/lxc_cgroup.h
+++ b/src/lxc/lxc_cgroup.h
@@ -29,7 +29,6 @@ virCgroup *virLXCCgroupCreate(virDomainDef *def,
                                 pid_t initpid,
                                 size_t nnicindexes,
                                 int *nicindexes);
-virCgroup *virLXCCgroupJoin(virDomainDef *def);
 int virLXCCgroupSetup(virDomainDef *def,
                       virCgroup *cgroup,
                       virBitmap *nodemask);
diff --git a/src/lxc/lxc_hostdev.h b/src/lxc/lxc_hostdev.h
index 34b813e3e9..4aa124c660 100644
--- a/src/lxc/lxc_hostdev.h
+++ b/src/lxc/lxc_hostdev.h
@@ -26,12 +26,6 @@
 
 int virLXCUpdateActiveUSBHostdevs(virLXCDriver *driver,
                                   virDomainDef *def);
-int virLXCFindHostdevUSBDevice(virDomainHostdevDef *hostdev,
-                               bool mandatory,
-                               virUSBDevice **usb);
-int virLXCPrepareHostdevUSBDevices(virLXCDriver *driver,
-                                   const char *name,
-                                   virUSBDeviceList *list);
 int virLXCPrepareHostDevices(virLXCDriver *driver,
                              virDomainDef *def);
 void virLXCDomainReAttachHostDevices(virLXCDriver *driver,
diff --git a/src/lxc/lxc_monitor.h b/src/lxc/lxc_monitor.h
index 5b5954f8e9..0a10768452 100644
--- a/src/lxc/lxc_monitor.h
+++ b/src/lxc/lxc_monitor.h
@@ -53,6 +53,3 @@ virLXCMonitor *virLXCMonitorNew(virDomainObj *vm,
                                   virLXCMonitorCallbacks *cb);
 
 void virLXCMonitorClose(virLXCMonitor *mon);
-
-void virLXCMonitorLock(virLXCMonitor *mon);
-void virLXCMonitorUnlock(virLXCMonitor *mon);
diff --git a/src/lxc/lxc_process.h b/src/lxc/lxc_process.h
index 4b84e31fef..95eacdd1e5 100644
--- a/src/lxc/lxc_process.h
+++ b/src/lxc/lxc_process.h
@@ -33,15 +33,6 @@ int virLXCProcessStop(virLXCDriver *driver,
                       virDomainShutoffReason reason,
                       unsigned int cleanupFlags);
 
-void virLXCProcessAutoDestroyRun(virLXCDriver *driver,
-                                 virConnectPtr conn);
-void virLXCProcessAutoDestroyShutdown(virLXCDriver *driver);
-int virLXCProcessAutoDestroyAdd(virLXCDriver *driver,
-                                virDomainObj *vm,
-                                virConnectPtr conn);
-int virLXCProcessAutoDestroyRemove(virLXCDriver *driver,
-                                   virDomainObj *vm);
-
 void virLXCProcessAutostartAll(virLXCDriver *driver);
 int virLXCProcessReconnectAll(virLXCDriver *driver,
                               virDomainObjList *doms);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index fb4551a7d0..76c514b5f7 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -93,7 +93,6 @@ qemuBuildNicDevProps(virDomainDef *def,
                      virDomainNetDef *net,
                      virQEMUCaps *qemuCaps);
 
-char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk);
 bool qemuDiskBusIsSD(int bus);
 
 int
@@ -208,8 +207,6 @@ qemuBuildRedirdevDevProps(const virDomainDef *def,
 virJSONValue *
 qemuBuildZPCIDevProps(virDomainDeviceInfo *dev);
 
-int qemuNetworkPrepareDevices(virDomainDef *def);
-
 bool
 qemuDiskConfigBlkdeviotuneEnabled(const virDomainDiskDef *disk);
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index a19314b48b..047a11b7fe 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -588,8 +588,6 @@ virDomainObj *qemuDomainObjFromDomain(virDomainPtr domain);
 
 qemuDomainSaveCookie *qemuDomainSaveCookieNew(virDomainObj *vm);
 
-void qemuDomainEventFlush(int timer, void *opaque);
-
 qemuMonitor *qemuDomainGetMonitor(virDomainObj *vm)
     ATTRIBUTE_NONNULL(1);
 void qemuDomainObjEnterMonitor(virDomainObj *obj)
@@ -645,9 +643,6 @@ void qemuDomainObjTaint(virQEMUDriver *driver,
                         virDomainTaintFlags taint,
                         qemuLogContext *logCtxt);
 
-char **qemuDomainObjGetTainting(virQEMUDriver *driver,
-                                virDomainObj *obj);
-
 void qemuDomainObjCheckTaint(virQEMUDriver *driver,
                              virDomainObj *obj,
                              qemuLogContext *logCtxt,
@@ -716,10 +711,6 @@ int qemuDomainCheckDiskStartupPolicy(virQEMUDriver *driver,
                                      size_t diskIndex,
                                      bool cold_boot);
 
-int qemuDomainCheckDiskPresence(virQEMUDriver *driver,
-                                virDomainObj *vm,
-                                unsigned int flags);
-
 int qemuDomainStorageSourceValidateDepth(virStorageSource *src,
                                          int add,
                                          const char *diskdst);
@@ -947,9 +938,6 @@ int qemuDomainSecretPrepare(virQEMUDriver *driver,
                             virDomainObj *vm)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
-int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
-                                    virQEMUCaps *qemuCaps);
-
 int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk,
                                      unsigned int parseFlags);
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 4341519cfe..035c9a7e3c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -939,10 +939,6 @@ void qemuMonitorChardevInfoFree(void *data);
 int qemuMonitorGetChardevInfo(qemuMonitor *mon,
                               GHashTable **retinfo);
 
-int qemuMonitorAttachPCIDiskController(qemuMonitor *mon,
-                                       const char *bus,
-                                       virPCIDeviceAddress *guestAddr);
-
 int qemuMonitorAddDeviceProps(qemuMonitor *mon,
                               virJSONValue **props);
 
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 10491b809b..ab3c2cb7c8 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -175,10 +175,6 @@ qemuMonitorJSONMigrate(qemuMonitor *mon,
 int
 qemuMonitorJSONGetMigrationBlockers(qemuMonitor *mon,
                                     char ***blockers);
-int
-qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitor *mon,
-                                       bool *spice_migrated);
-
 
 int
 qemuMonitorJSONMigrateCancel(qemuMonitor *mon);
@@ -208,26 +204,6 @@ qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon,
                                 int tlsPort,
                                 const char *tlsSubject);
 
-int
-qemuMonitorJSONAddPCIHostDevice(qemuMonitor *mon,
-                                virPCIDeviceAddress *hostAddr,
-                                virPCIDeviceAddress *guestAddr);
-
-int
-qemuMonitorJSONAddPCIDisk(qemuMonitor *mon,
-                          const char *path,
-                          const char *bus,
-                          virPCIDeviceAddress *guestAddr);
-
-int
-qemuMonitorJSONAddPCINetwork(qemuMonitor *mon,
-                             const char *nicstr,
-                             virPCIDeviceAddress *guestAddr);
-
-int
-qemuMonitorJSONRemovePCIDevice(qemuMonitor *mon,
-                               virPCIDeviceAddress *guestAddr);
-
 int
 qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon,
                                   int fd,
@@ -268,11 +244,6 @@ int
 qemuMonitorJSONGetChardevInfo(qemuMonitor *mon,
                               GHashTable *info);
 
-int
-qemuMonitorJSONAttachPCIDiskController(qemuMonitor *mon,
-                                       const char *bus,
-                                       virPCIDeviceAddress *guestAddr);
-
 int
 qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
                               virJSONValue **props);
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 878c522d82..12781673c5 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -189,9 +189,6 @@ void qemuProcessShutdownOrReboot(virDomainObj *vm);
 void qemuProcessAutoDestroy(virDomainObj *dom,
                             virConnectPtr conn);
 
-int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
-                              virDomainThreadSchedParam *sp);
-
 virDomainDiskDef *qemuProcessFindDomainDiskByAliasOrQOM(virDomainObj *vm,
                                                           const char *alias,
                                                           const char *qomid);
diff --git a/src/rpc/virnetlibsshsession.h b/src/rpc/virnetlibsshsession.h
index 7f94fd15dc..949680035c 100644
--- a/src/rpc/virnetlibsshsession.h
+++ b/src/rpc/virnetlibsshsession.h
@@ -26,7 +26,6 @@
 typedef struct _virNetLibsshSession virNetLibsshSession;
 
 virNetLibsshSession *virNetLibsshSessionNew(const char *username);
-void virNetLibsshSessionFree(virNetLibsshSession *sess);
 
 typedef enum {
     VIR_NET_LIBSSH_HOSTKEY_VERIFY_NORMAL,
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index 2ae6c85b20..0a1ddd6f28 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -152,8 +152,6 @@ int virNetServerClientInit(virNetServerClient *client);
 int virNetServerClientInitKeepAlive(virNetServerClient *client,
                                     int interval,
                                     unsigned int count);
-bool virNetServerClientCheckKeepAlive(virNetServerClient *client,
-                                      virNetMessage *msg);
 int virNetServerClientStartKeepAlive(virNetServerClient *client);
 
 const char *virNetServerClientLocalAddrStringSASL(virNetServerClient *client);
diff --git a/src/util/virmdev.h b/src/util/virmdev.h
index e8e69040e5..75853bc0ff 100644
--- a/src/util/virmdev.h
+++ b/src/util/virmdev.h
@@ -72,9 +72,6 @@ typedef int (*virMediatedDeviceCallback)(virMediatedDevice *dev,
 virMediatedDevice *
 virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model);
 
-virMediatedDevice *
-virMediatedDeviceCopy(virMediatedDevice *dev);
-
 void
 virMediatedDeviceFree(virMediatedDevice *dev);
 
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index c287a7b272..99fe761c1d 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -185,16 +185,6 @@ int virNetDevGetMAC(const char *ifname,
                     virMacAddr *macaddr)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
 
-int virNetDevReplaceMacAddress(const char *linkdev,
-                               const virMacAddr *macaddress,
-                               const char *stateDir)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-    G_GNUC_WARN_UNUSED_RESULT;
-
-int virNetDevRestoreMacAddress(const char *linkdev,
-                               const char *stateDir)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
-
 int virNetDevSetCoalesce(const char *ifname,
                          virNetDevCoalesce *coalesce,
                          bool update)
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index 7a797953a5..a7003a5370 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -39,14 +39,6 @@
 
 #define IS_CT(def)  (def->os.type == VIR_DOMAIN_OSTYPE_EXE)
 
-#define vzDomNotFoundError(domain) \
-    do { \
-        char uuidstr[VIR_UUID_STRING_BUFLEN]; \
-        virUUIDFormat(domain->uuid, uuidstr); \
-        virReportError(VIR_ERR_NO_DOMAIN, \
-                       _("no domain with matching uuid '%1$s'"), uuidstr); \
-    } while (0)
-
 #define PARALLELS_DOMAIN_ROUTED_NETWORK_NAME   "host-routed"
 #define VIRTUOZZO_VER_7 ((unsigned long)7000000)
 
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 90632031ff..74e307d653 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -126,9 +126,6 @@ typedef struct _testQemuInfo testQemuInfo;
 void testQemuInfoFree(testQemuInfo *info);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(testQemuInfo, testQemuInfoFree);
 
-virDomainXMLOption *testQemuXMLConfInit(void);
-
-
 virQEMUCaps *qemuTestParseCapabilitiesArch(virArch arch,
                                              const char *capsFile);
 virCPUDef *qemuTestGetCPUDef(qemuTestCPUDef d);
-- 
2.45.2
Re: [PATCH] Drop unused function declarations
Posted by Ján Tomko 1 week, 1 day ago
On a Tuesday in 2024, Michal Privoznik wrote:
>When moving function and/or renaming them sometimes corresponding
>change to corresponding header file is not done. This leaves us
>with functions that are declared in header files, but nowhere
>implemented. Drop such declarations.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
>
>These were identified by a bash oneliner which basically tried to list
>every "function" in every header file (function was matched as '\w\+(')
>and for every function from the list, git grep was done to see if it
>lives in a .c file.
>
>It's nowhere exhaustive or perfect, but if found at least something.
>
> src/ch/ch_monitor.h           |  4 ----
> src/conf/device_conf.h        |  1 -
> src/conf/virinterfaceobj.h    |  3 ---
> src/conf/virstorageobj.h      |  3 ---
> src/libxl/libxl_domain.h      |  3 ---
> src/logging/log_handler.h     |  2 --
> src/lxc/lxc_cgroup.h          |  1 -
> src/lxc/lxc_hostdev.h         |  6 ------
> src/lxc/lxc_monitor.h         |  3 ---
> src/lxc/lxc_process.h         |  9 ---------
> src/qemu/qemu_command.h       |  3 ---
> src/qemu/qemu_domain.h        | 12 ------------
> src/qemu/qemu_monitor.h       |  4 ----
> src/qemu/qemu_monitor_json.h  | 29 -----------------------------
> src/qemu/qemu_process.h       |  3 ---
> src/rpc/virnetlibsshsession.h |  1 -
> src/rpc/virnetserverclient.h  |  2 --
> src/util/virmdev.h            |  3 ---
> src/util/virnetdev.h          | 10 ----------
> src/vz/vz_utils.h             |  8 --------
> tests/testutilsqemu.h         |  3 ---
> 21 files changed, 113 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano