Skip to contentSkip to conversation

libmpathpersist: use extern struct udev from main program

PATCH In review Martin Wilck 3 participants 3 messages Mar 26, 2017 – Jun 21, 2017 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libmpathpersist: use extern struct udev from main program

Use the global variable "udev" - the internal one is not initialized, causing current libudev calls to fail. In the main program "mpathpersist", use a globally visible variable "udev" rather than a local variable in main(). This imitates the way the global variable "udev" is used in multipath and multipathd.

Removed the "udev" parameter from mpath_lib_init() to clarify that it isn't used.

Fixes b87454988 "libmultipath: separate out 'udev' config entry"
---
 libmpathpersist/mpath_persist.c | 4 ++--
 libmpathpersist/mpath_persist.h | 2 +-
 mpathpersist/main.c             | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
libmpathpersist/mpath_persist.c +2 -2
index 982c7954..9bca7764 100644
@@ -34,10 +34,10 @@
 
 #define __STDC_FORMAT_MACROS 1
 
-struct udev *udev;
+extern struct udev *udev;
 
 struct config *
-mpath_lib_init (struct udev *udev)
+mpath_lib_init (void)
 {
 	struct config *conf;
 
libmpathpersist/mpath_persist.h +1 -1
index 79de5b5b..7422322d 100644
@@ -174,7 +174,7 @@ struct prout_param_descriptor {		/* PROUT parameter descriptor */
  *
  * RETURNS: struct config ->Success, NULL->Failed.
  */
-extern struct config * mpath_lib_init (struct udev *udev);
+extern struct config * mpath_lib_init (void);
 
 
 /*
mpathpersist/main.c +3 -2
index 2e0aba3c..e1aac8fa 100644
@@ -57,6 +57,8 @@ void rcu_register_thread_memb(void) {}
 
 void rcu_unregister_thread_memb(void) {}
 
+struct udev *udev;
+
 int main (int argc, char * argv[])
 {
 	int fd, c, res;
@@ -86,7 +88,6 @@ int main (int argc, char * argv[])
 	int num_transport =0;
 	void *resp = NULL;
 	struct transportid * tmp;
-	struct udev *udev = NULL;
 	struct config *conf;
 
 	if (optind == argc)
@@ -104,7 +105,7 @@ int main (int argc, char * argv[])
 	}
 
 	udev = udev_new();
-	conf = mpath_lib_init(udev);
+	conf = mpath_lib_init();
 	if(!conf) {
 		udev_unref(udev);
 		exit(1);
Signature · 1 line
2.12.0
#1 lore raw
Quoted 10 lines · Martin Wilck

Use the global variable "udev" - the internal one is not initialized, causing current libudev calls to fail. In the main program "mpathpersist", use a globally visible variable "udev" rather than a local variable in main(). This imitates the way the global variable "udev" is used in multipath and multipathd.

Removed the "udev" parameter from mpath_lib_init() to clarify that it isn't used.

ACK

-Ben

Quoted 75 lines
Fixes b87454988 "libmultipath: separate out 'udev' config entry"
---
 libmpathpersist/mpath_persist.c | 4 ++--
 libmpathpersist/mpath_persist.h | 2 +-
 mpathpersist/main.c             | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
libmpathpersist/mpath_persist.c +2 -2
index 982c7954..9bca7764 100644
@@ -34,10 +34,10 @@
 
 #define __STDC_FORMAT_MACROS 1
 
-struct udev *udev;
+extern struct udev *udev;
 
 struct config *
-mpath_lib_init (struct udev *udev)
+mpath_lib_init (void)
 {
 	struct config *conf;
 
libmpathpersist/mpath_persist.h +1 -1
index 79de5b5b..7422322d 100644
@@ -174,7 +174,7 @@ struct prout_param_descriptor {		/* PROUT parameter descriptor */
  *
  * RETURNS: struct config ->Success, NULL->Failed.
  */
-extern struct config * mpath_lib_init (struct udev *udev);
+extern struct config * mpath_lib_init (void);
 
 
 /*
mpathpersist/main.c +3 -2
index 2e0aba3c..e1aac8fa 100644
@@ -57,6 +57,8 @@ void rcu_register_thread_memb(void) {}
 
 void rcu_unregister_thread_memb(void) {}
 
+struct udev *udev;
+
 int main (int argc, char * argv[])
 {
 	int fd, c, res;
@@ -86,7 +88,6 @@ int main (int argc, char * argv[])
 	int num_transport =0;
 	void *resp = NULL;
 	struct transportid * tmp;
-	struct udev *udev = NULL;
 	struct config *conf;
 
 	if (optind == argc)
@@ -104,7 +105,7 @@ int main (int argc, char * argv[])
 	}
 
 	udev = udev_new();
-	conf = mpath_lib_init(udev);
+	conf = mpath_lib_init();
 	if(!conf) {
 		udev_unref(udev);
 		exit(1);
Signature · 6 lines
2.12.0

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#2 lore raw

Merged.
Thanks.

Quoted 100 lines · Benjamin Marzinski
Quoted 10 lines · Martin Wilck

Use the global variable "udev" - the internal one is not initialized, causing current libudev calls to fail. In the main program "mpathpersist", use a globally visible variable "udev" rather than a local variable in main(). This imitates the way the global variable "udev" is used in multipath and multipathd.

Removed the "udev" parameter from mpath_lib_init() to clarify that it isn't used.

ACK

-Ben

libmpathpersist/mpath_

Quoted 9 lines
Fixes b87454988 "libmultipath: separate out 'udev' config entry"
---
 libmpathpersist/mpath_persist.c | 4 ++--
 libmpathpersist/mpath_persist.h | 2 +-
 mpathpersist/main.c             | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
libmpathpersist/mpath_ renamed from libmpathpersist/mpath_persist.c +0 -0

persist.c

libmpathpersist/mpath_

Quoted 17 lines

index 982c7954..9bca7764 100644

libmpathpersist/mpath_persist.c +2 -2
@@ -34,10 +34,10 @@
 
 #define __STDC_FORMAT_MACROS 1
 
-struct udev *udev;
+extern struct udev *udev;
 
 struct config *
-mpath_lib_init (struct udev *udev)
+mpath_lib_init (void)
 {
      struct config *conf;
 
libmpathpersist/mpath_ renamed from libmpathpersist/mpath_persist.h +0 -0

persist.h

libmpathpersist/mpath_persist.h struct prout_param_descriptor { /* PROUT

Quoted 4 lines

index 79de5b5b..7422322d 100644

libmpathpersist/mpath_persist.h +0 -0
@@ -174,7 +174,7 @@ struct prout_param_descriptor {           /* PROUT

parameter descriptor */

Quoted 41 lines
libmpathpersist/mpath_persist.h +1 -1
  *
  * RETURNS: struct config ->Success, NULL->Failed.
  */
-extern struct config * mpath_lib_init (struct udev *udev);
+extern struct config * mpath_lib_init (void);
 
 
 /*
mpathpersist/main.c +3 -3
index 2e0aba3c..e1aac8fa 100644
@@ -57,6 +57,8 @@ void rcu_register_thread_memb(void) {}
 
 void rcu_unregister_thread_memb(void) {}
 
+struct udev *udev;
+
 int main (int argc, char * argv[])
 {
      int fd, c, res;
@@ -86,7 +88,6 @@ int main (int argc, char * argv[])
      int num_transport =0;
      void *resp = NULL;
      struct transportid * tmp;
-     struct udev *udev = NULL;
      struct config *conf;
 
      if (optind == argc)
@@ -104,7 +105,7 @@ int main (int argc, char * argv[])
      }
 
      udev = udev_new();
-     conf = mpath_lib_init(udev);
+     conf = mpath_lib_init();
      if(!conf) {
              udev_unref(udev);
              exit(1);
--

2.12.0

Quoted 4 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel