Skip to contentSkip to conversation

Three multipath-tools source code cleanup patches

PATCH Applied Bart Van Assche 4 participants 9 messages Dec 12, 2017 – Jan 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Three multipath-tools source code cleanup patches

Hello Christophe,

The three patches in this series make it easier to compile the multipath-tools source code with sparse and address two issues discovered by sparse. Please consider these patches for inclusion in the upstream multipath-tools repository.

Thanks,

Bart.

Bart Van Assche (3):
Makefile.inc: Allow additional CFLAGS to be specified on the command
line
Allow the compiler to verify the consistency of the uxsock_timeout
definition and declaration
multipathd/cli.h: Add a header file guard

 Makefile.inc      | 3 ++-
 multipathd/cli.h  | 5 +++++
 multipathd/main.c | 3 +--
 3 files changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 Makefile.inc: Allow additional CFLAGS to be specified on the command line

Compiling the multipath-tools source code with e.g. sparse requires to specify additional compiler flags on the command line. Modify the Makefile such that this becomes possible.

---
 Makefile.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile.inc +2 -1
index 29c290a22e8f..d953f5ef34e6 100644
@@ -90,7 +90,8 @@ OPTFLAGS	= -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
 		  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
 		  --param=ssp-buffer-size=4
 
-CFLAGS		= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"
+CFLAGS		:= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
+		   $(CFLAGS)
 BIN_CFLAGS	= -fPIE -DPIE
 LIB_CFLAGS	= -fPIC
 SHARED_FLAGS	= -shared
Signature · 1 line
2.15.1
#2 lore raw

Re: [PATCH 1/3] Makefile.inc: Allow additional CFLAGS to be specified on the command line

These two pending patches are incompatible.

-------- Forwarded Message --------
Subject: [dm-devel] [PATCH 1/3] Makefile.inc: Allow additional CFLAGS to be specified on the command line
Date: Mon, 11 Dec 2017 16:45:01 -0800
From: Bart Van Assche <[email protected]>
To: Christophe Varoqui <[email protected]>
CC: Bart Van Assche <[email protected]>, [email protected]

Compiling the multipath-tools source code with e.g. sparse requires to specify additional compiler flags on the command line. Modify the Makefile such that this becomes possible.

---
 Makefile.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile.inc +2 -0
index 29c290a22e8f..d953f5ef34e6 100644
@@ -90,7 +90,8 @@ OPTFLAGS	= -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
 		  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
 		  --param=ssp-buffer-size=4
 -CFLAGS		= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"
+CFLAGS		:= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
+		   $(CFLAGS)
 BIN_CFLAGS	= -fPIE -DPIE
 LIB_CFLAGS	= -fPIC
 SHARED_FLAGS	= -shared
Signature · 16 lines
2.15.1


-------- Forwarded Message --------
Subject: [dm-devel] [PATCH] multipath-tools: Makefile: Respect standard toolchain related envvars
Date: Thu, 30 Nov 2017 00:23:11 +0100
From: Thomas Deutschmann <[email protected]>
To: [email protected]

The Makefile overrides standard envvars that control the toolchain flags.
This patch should set things right without reducing default behavior.

Signed-off-by: Thomas Deutschmann <[email protected]>
---
 Makefile.inc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile.inc +3 -1
index 29c290a2..951d58fc 100644
@@ -90,11 +90,12 @@ OPTFLAGS	= -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
 		  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
 		  --param=ssp-buffer-size=4
 -CFLAGS		= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"
+CFLAGS		?= $(OPTFLAGS)
+CFLAGS		+= -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"
 BIN_CFLAGS	= -fPIE -DPIE
 LIB_CFLAGS	= -fPIC
 SHARED_FLAGS	= -shared
-LDFLAGS		= -Wl,-z,relro -Wl,-z,now
+LDFLAGS		+= -Wl,-z,relro -Wl,-z,now
 BIN_LDFLAGS	= -pie
  # Check whether a function with name $1 has been declared in header file $2.
Signature · 1 line
2.15.1
#3 lore raw

Re: [PATCH 1/3] Makefile.inc: Allow additional CFLAGS to be specified on the command line

In reply to Bart Van Assche

Hi Bart,

Quoted 14 lines · Bart Van Assche

Compiling the multipath-tools source code with e.g. sparse requires to specify additional compiler flags on the command line. Modify the Makefile such that this becomes possible.

---
 Makefile.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile.inc +0 -0
index 29c290a22e8f..d953f5ef34e6 100644

Makefile.inc OPTFLAGS = -O2 -g -pipe -Wall -Wextra · line 94

Quoted 9 lines
Makefile.inc +2 -4
@@ -90,7 +90,8 @@ OPTFLAGS	= -O2 -g -pipe -Wall -Wextra
-Wformat=2 -Werror=implicit-int \
 		  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
 		  --param=ssp-buffer-size=4
 
-CFLAGS		= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\"
-DRUN_DIR=\"${RUN}\"
+CFLAGS		:= $(OPTFLAGS) -DLIB_STRING=\"${LIB}\"
-DRUN_DIR=\"${RUN}\" \
+		   $(CFLAGS)

I'd prefer the variable passed from user space not to be called CFLAGS but e.g. EXTRA_CFLAGS. Otherwise, ack.

Martin

Quoted 3 lines

BIN_CFLAGS = -fPIE -DPIE
LIB_CFLAGS = -fPIC
SHARED_FLAGS = -shared

Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

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

PATCH 2/3 Allow the compiler to verify the consistency of the uxsock_timeout definition and declaration

In reply to Bart Van Assche

Global variables should be defined after the header file with their declaration has been included. Hence move the declaration of usock_timeout further down.

---
 multipathd/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
multipathd/main.c +1 -2
index 31ce923385a7..d611597a4ef8 100644
@@ -39,8 +39,6 @@
 static int use_watchdog;
 #endif
 
-int uxsock_timeout;
-
 /*
  * libmultipath
  */
@@ -106,6 +104,7 @@ struct mpath_event_param
 };
 
 int logsink;
+int uxsock_timeout;
 int verbosity;
 int bindings_read_only;
 int ignore_new_devs;
Signature · 1 line
2.15.1
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] Allow the compiler to verify the consistency of the uxsock_timeout definition and declaration

Quoted 9 lines · Bart Van Assche

Global variables should be defined after the header file with their declaration has been included. Hence move the declaration of usock_timeout further down.

---
 multipathd/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

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

PATCH 3/3 multipathd/cli.h: Add a header file guard

In reply to Bart Van Assche

This patch avoids that compilation breaks if the multipathd/cli.h header file is included multiple times from the same compilation unit.

---
 multipathd/cli.h | 5 +++++
 1 file changed, 5 insertions(+)
multipathd/cli.h +5 -0
index d289167e20ff..021f25b7085a 100644
@@ -1,3 +1,6 @@
+#ifndef _CLI_H_
+#define _CLI_H_
+
 #include <stdint.h>
 
 enum {
@@ -126,3 +129,5 @@ void free_handlers (void);
 int cli_init (void);
 void cli_exit(void);
 char * key_generator (const char * str, int state);
+
+#endif /* _CLI_H_ */
Signature · 1 line
2.15.1
Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] multipathd/cli.h: Add a header file guard

Quoted 8 lines · Bart Van Assche

This patch avoids that compilation breaks if the multipathd/cli.h header file is included multiple times from the same compilation unit.

---
 multipathd/cli.h | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#8 lore raw
In reply to Bart Van Assche

Applied,
Thanks.

Quoted 28 lines · Bart Van Assche

Hello Christophe,

The three patches in this series make it easier to compile the multipath-tools
source code with sparse and address two issues discovered by sparse. Please consider these patches for inclusion in the upstream multipath-tools repository.

Thanks,

Bart.

Bart Van Assche (3):
Makefile.inc: Allow additional CFLAGS to be specified on the command
line
Allow the compiler to verify the consistency of the uxsock_timeout
definition and declaration
multipathd/cli.h: Add a header file guard

 Makefile.inc      | 3 ++-
 multipathd/cli.h  | 5 +++++
 multipathd/main.c | 3 +--
 3 files changed, 8 insertions(+), 3 deletions(-)

--
2.15.1