[PATCH 0/5] node_device: Tiny code cleanups

My aim is to move virNodeDeviceDriver declaration into node_device_driver.c, eventually. BUT that's going to be more patches and as I continue my work on that I've noticed couple of almost trivial patches that can be merged regardless. Even during freeze ;-) Michal Prívozník (5): node_device_udev.h: Drop unused macro node_device: Move DMI_DEVPATH into node_device_udev.c node_device_udev.h: Drop include of libudev.h node_device: Move fwd declaration of udevNodeRegister() into correct header file node_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations src/node_device/node_device_driver.c | 3 +++ src/node_device/node_device_driver.h | 12 ------------ src/node_device/node_device_udev.c | 2 ++ src/node_device/node_device_udev.h | 6 ++---- 4 files changed, 7 insertions(+), 16 deletions(-) -- 2.37.4

The SYSFS_DATA_SIZE macro is Unused since its introduction in v0.7.3~48. Sorry Dave. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/node_device/node_device_udev.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index eab22a9182..fac0caf5fb 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -22,5 +22,4 @@ #include <libudev.h> -#define SYSFS_DATA_SIZE 4096 #define DMI_DEVPATH "/sys/devices/virtual/dmi/id" -- 2.37.4

The DMI_DEVPATH macro is used exclusively within node_device_udev.c. There's no need to expose it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/node_device/node_device_udev.c | 2 ++ src/node_device/node_device_udev.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 07c10f0d88..24ef1c25a9 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -52,6 +52,8 @@ VIR_LOG_INIT("node_device.node_device_udev"); # define TYPE_RAID 12 #endif +#define DMI_DEVPATH "/sys/devices/virtual/dmi/id" + typedef struct _udevEventData udevEventData; struct _udevEventData { virObjectLockable parent; diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index fac0caf5fb..911eda2c80 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -21,5 +21,3 @@ #pragma once #include <libudev.h> - -#define DMI_DEVPATH "/sys/devices/virtual/dmi/id" -- 2.37.4

Nothing in the header file requires the include of libudev.h, as the former header file is now empty. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/node_device/node_device_udev.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index 911eda2c80..8f60cbfe1b 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -19,5 +19,3 @@ */ #pragma once - -#include <libudev.h> -- 2.37.4

Currently, udevNodeRegister() is forward declared in node_device_driver.h even though the function is implemented in node_device_udev.c which warrants node_device_udev.h header file. Move the declaration into the correct file. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/node_device/node_device_driver.c | 3 +++ src/node_device/node_device_driver.h | 6 ------ src/node_device/node_device_udev.h | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 8e93b0dd6f..5bde05d593 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -35,6 +35,9 @@ #include "node_device_conf.h" #include "node_device_event.h" #include "node_device_driver.h" +#if WITH_UDEV +# include "node_device_udev.h" +#endif #include "virvhba.h" #include "viraccessapicheck.h" #include "virutil.h" diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 7311b603ac..6f835bc71a 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -28,12 +28,6 @@ #define LINUX_NEW_DEVICE_WAIT_TIME 60 -#ifdef WITH_UDEV -int -udevNodeRegister(void); -#endif - - typedef enum { MDEVCTL_CMD_START, MDEVCTL_CMD_STOP, diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index 8f60cbfe1b..3d1a156863 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -19,3 +19,6 @@ */ #pragma once + +int +udevNodeRegister(void); -- 2.37.4

The node_device_driver.h declares nodeDeviceLock() and nodeDeviceUnlock() functions which used to exist, but after rework to automatic mutex management they exist no more. Their last use was removed in v8.1.0-rc1~122. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/node_device/node_device_driver.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 6f835bc71a..c7d5e22daf 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -46,12 +46,6 @@ typedef enum { VIR_ENUM_DECL(virMdevctlCommand); -void -nodeDeviceLock(void); - -void -nodeDeviceUnlock(void); - extern virNodeDeviceDriverState *driver; int -- 2.37.4

On 10/25/22 10:15 AM, Michal Privoznik wrote:
My aim is to move virNodeDeviceDriver declaration into node_device_driver.c, eventually. BUT that's going to be more patches and as I continue my work on that I've noticed couple of almost trivial patches that can be merged regardless. Even during freeze ;-)
Michal Prívozník (5): node_device_udev.h: Drop unused macro node_device: Move DMI_DEVPATH into node_device_udev.c node_device_udev.h: Drop include of libudev.h node_device: Move fwd declaration of udevNodeRegister() into correct header file node_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations
src/node_device/node_device_driver.c | 3 +++ src/node_device/node_device_driver.h | 12 ------------ src/node_device/node_device_udev.c | 2 ++ src/node_device/node_device_udev.h | 6 ++---- 4 files changed, 7 insertions(+), 16 deletions(-)
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
participants (2)
-
Jonathon Jongsma
-
Michal Privoznik