Minor fixes for multipath-tools
Subsystems (2)
cover Minor fixes for multipath-tools
From: Martin Wilck <[email protected]>
Hi Christophe, hi Ben,
This series fixes a couple of issues I recently found with the 32bit build of multipath-tools, and after integrating our CI into the automated builds on our build server.
Regards
Martin
Martin Wilck (11):
multipath-tools: Makefile: more dependency fixes for parallel build
multipath-tools: Makefile.inc: separate out OPTFLAGS
multipath-tools: Makefile.inc: allow user settings for LDFLAGS
multipath-tools: Makefile.inc: set -Wno-error=clobbered
libmultipath: discovery.c: use %z qualifier for size_t
libmultipath: eliminate more signed/unsigned comparisons
libmultipath: set_uint: fix parsing for 32bit multipath-tools tests/Makefile: add -lmpathcmd to LIBDEPS multipath tools tests/Makefile: Fix OBJDEPS for hwtable-test multipath-tools tests/test-lib.c: drop __wrap_is_claimed_by_foreign multipath-tools tests/directio: fix -Wmaybe-uninitalized warning
Makefile | 5 +++-- Makefile.inc | 16 ++++++++-------- libmpathpersist/mpath_pr_ioctl.c | 2 +- libmultipath/dict.c | 11 +++++++---- libmultipath/discovery.c | 16 ++++++++-------- libmultipath/print.c | 12 ++++++------ libmultipath/prioritizers/alua_spc3.h | 2 +- multipathd/cli_handlers.c | 20 ++++++++++---------- multipathd/main.c | 2 +- tests/Makefile | 4 ++-- tests/directio.c | 2 +- tests/test-lib.c | 6 ------ 12 files changed, 48 insertions(+), 50 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/11 multipath-tools: Makefile: more dependency fixes for parallel build
From: Martin Wilck <[email protected]>
Extend the late fixes from Christian.
--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -28,8 +28,9 @@ all: $(BUILDDIRS) $(BUILDDIRS): $(MAKE) -C $@ -libmpathpersist multipath multipathd mpathpersist: libmultipath -mpathpersist: libmpathpersist +libmultipath libdmmp: libmpathcmd +libmpathpersist multipath multipathd: libmultipath +mpathpersist multipathd: libmpathpersist $(BUILDDIRS.clean): $(MAKE) -C ${@:.clean=} clean
Signature · 1 line
2.26.2
PATCH 2/11 multipath-tools: Makefile.inc: separate out OPTFLAGS
In reply to [email protected]From: Martin Wilck <[email protected]>
OPTFLAGS is what distribution builds would typically override. That should not include the warning flags we use.
Moreover, in the definition of CFLAGS, put $(CFLAGS) first to make it easier for the user to spot her input in the build logs.
--- Makefile.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Makefile.inc +6 -6
@@ -93,14 +93,14 @@ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,) -OPTFLAGS = -O2 -g -pipe -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \ +OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 +WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \ -Werror=implicit-function-declaration -Werror=format-security \ - $(WNOCLOBBERED) \ - -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ - $(STACKPROT) --param=ssp-buffer-size=4 + $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) CPPFLAGS := -Wp,-D_FORTIFY_SOURCE=2 -CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ - -MMD -MP $(CFLAGS) +CFLAGS := $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ + -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ + -MMD -MP BIN_CFLAGS = -fPIE -DPIE LIB_CFLAGS = -fPIC SHARED_FLAGS = -shared
Signature · 1 line
2.26.2
PATCH 3/11 multipath-tools: Makefile.inc: allow user settings for LDFLAGS
In reply to [email protected]From: Martin Wilck <[email protected]>
This allows e.g. setting LDFLAGS="-m32 -Wl,-b,elf32-i386" to compile for a 32bit target on a 64bit system.
Note that, like CFLAGS, the variable needs to be set in the environment, not on the "make" command line.
--- Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.inc +1 -1
@@ -104,7 +104,7 @@ CFLAGS := $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ BIN_CFLAGS = -fPIE -DPIE LIB_CFLAGS = -fPIC SHARED_FLAGS = -shared -LDFLAGS = -Wl,-z,relro -Wl,-z,now +LDFLAGS := $(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.26.2
PATCH 4/11 multipath-tools: Makefile.inc: set -Wno-error=clobbered
In reply to [email protected]From: Martin Wilck <[email protected]>
We need to ignore -Wclobbered because gcc has trouble dealing with glibc's implementation of pthread_cleanup_push().
For some variants of gcc, -Wno-clobbered alone isn't enough if -Werror is also set. Compilation with -Wno-error=clobbered works, though.
--- Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.inc +1 -1
@@ -91,7 +91,7 @@ TEST_CC_OPTION = $(shell \ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) -WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,) +WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,) OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \
Signature · 1 line
2.26.2
PATCH 5/11 libmultipath: discovery.c: use %z qualifier for size_t
In reply to [email protected]From: Martin Wilck <[email protected]>
Otherwise compilation for 32bit targets spits out warnings.
--- libmultipath/discovery.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
libmultipath/discovery.c +8 -8
@@ -986,7 +986,7 @@ parse_vpd_pg80(const unsigned char *in, char *out, size_t out_len) }if (len >= out_len) { -condlog (2 ,"vpd pg80 overflow, %lu/%lu bytes required" , +condlog (2 ,"vpd pg80 overflow, %zu/%zu bytes required" , len +1 , out_len); len = out_len -1 ; }
@@ -1087,7 +1087,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, len =sprintf (out,"%d" , vpd_type);if (2 * vpd_len >= out_len - len) { -condlog (1 ,"%s: WWID overflow, type %d, %lu/%lu bytes required" , +condlog (1 ,"%s: WWID overflow, type %d, %zu/%zu bytes required" , __func__, vpd_type,2 * vpd_len + len +1 , out_len); vpd_len = (out_len - len -1 ) /2 ;
@@ -1096,7 +1096,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, len +=sprintf (out + len,"%02x" , vpd[i]); }else if (vpd_type ==0x8 && vpd_len <4 ) { -condlog (1 ,"%s: VPD length %lu too small for designator type 8" , +condlog (1 ,"%s: VPD length %zu too small for designator type 8" , __func__, vpd_len);return -EINVAL ; }else if (vpd_type ==0x8 ) {
@@ -1112,7 +1112,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len,while (len >2 && vpd[len -2 ] =='\0' ) --len;if (len > out_len -1 ) { -condlog (1 ,"%s: WWID overflow, type 8/%c, %lu/%lu bytes required" , +condlog (1 ,"%s: WWID overflow, type 8/%c, %zu/%zu bytes required" , __func__, out[0 ], len +1 , out_len); len = out_len -1 ; }
@@ -1136,7 +1136,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len,while ((p =memchr (vpd,' ' , vpd_len))) { p_len = p - vpd;if (len + p_len > out_len -1 ) { -condlog (1 ,"%s: WWID overflow, type 1, %lu/%lu bytes required" , +condlog (1 ,"%s: WWID overflow, type 1, %zu/%zu bytes required" , __func__, len + p_len, out_len); p_len = out_len - len -1 ; }
@@ -1162,7 +1162,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, p_len = vpd_len;if (p_len >0 && len < out_len -1 ) {if (len + p_len > out_len -1 ) { -condlog (1 ,"%s: WWID overflow, type 1, %lu/%lu bytes required" , +condlog (1 ,"%s: WWID overflow, type 1, %zu/%zu bytes required" , __func__, len + p_len +1 , out_len); p_len = out_len - len -1 ; }
@@ -1186,14 +1186,14 @@ parse_vpd_c0_hp3par(const unsigned char *in, size_t in_len,memset (out,0x0 , out_len);if (in_len <=4 || (in[4 ] >3 && in_len <44 )) { -condlog (3 ,"HP/3PAR vendor specific VPD page length too short: %lu" , in_len); +condlog (3 ,"HP/3PAR vendor specific VPD page length too short: %zu" , in_len);return -EINVAL ; }if (in[4 ] <=3 )/* revision must be > 3 to have Vomlume Name */ return -ENODATA ; len =get_unaligned_be32 (&in[40 ]);if (len > out_len || len +44 > in_len) { -condlog (3 ,"HP/3PAR vendor specific Volume name too long: %lu" , +condlog (3 ,"HP/3PAR vendor specific Volume name too long: %zu" , len);return -EINVAL ; }
Signature · 1 line
2.26.2
PATCH 6/11 libmultipath: eliminate more signed/unsigned comparisons
In reply to [email protected]From: Martin Wilck <[email protected]>
Fix some more compiler warnings about signed/unsigned comparison. I've observed these only on 32bit builds, therefore they went unnoticed before.
--- libmpathpersist/mpath_pr_ioctl.c | 2 +- libmultipath/print.c | 12 ++++++------ libmultipath/prioritizers/alua_spc3.h | 2 +- multipathd/cli_handlers.c | 20 ++++++++++---------- multipathd/main.c | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-)
libmpathpersist/mpath_pr_ioctl.c +1 -1
@@ -238,7 +238,7 @@ static void mpath_format_readfullstatus(struct prin_resp *pr_buff)uint32_t additional_length, k, tid_len_len =0 ;char tempbuff[MPATH_MAX_PARAM_LEN ];struct prin_fulldescr fdesc; -static const int pbuf_size = +static const unsigned int pbuf_size =sizeof (pr_buff->prin_descriptor.prin_readfd.private_buffer);convert_be32_to_cpu (&pr_buff->prin_descriptor.prin_readfd.prgeneration);
libmultipath/print.c +6 -6
@@ -1958,25 +1958,25 @@ char *snprint_config(const struct config *conf, int *len, } c = reply +snprint_defaults (conf, reply, maxlen); -if ((c - reply) == maxlen) +if (c == reply + maxlen)continue ; c +=snprint_blacklist (conf, c, reply + maxlen - c); -if ((c - reply) == maxlen) +if (c == reply + maxlen)continue ; c +=snprint_blacklist_except (conf, c, reply + maxlen - c); -if ((c - reply) == maxlen) +if (c == reply + maxlen)continue ; c +=snprint_hwtable (conf, c, reply + maxlen - c, hwtable ? hwtable : conf->hwtable); -if ((c - reply) == maxlen) +if (c == reply + maxlen)continue ; c +=snprint_overrides (conf, c, reply + maxlen - c, conf->overrides); -if ((c - reply) == maxlen) +if (c == reply + maxlen)continue ; if (VECTOR_SIZE(conf->mptable) > 0 ||
@@ -1984,7 +1984,7 @@ char *snprint_config(const struct config *conf, int *len, c +=snprint_mptable (conf, c, reply + maxlen - c, mpvec); -if ((c - reply) < maxlen) { +if (c < reply + maxlen) {if (len) *len = c - reply;return reply;
libmultipath/prioritizers/alua_spc3.h +1 -1
@@ -284,7 +284,7 @@ struct rtpg_data {#define RTPG_FOR_EACH_PORT_GROUP (p, g) \ for( \ g = &(p->data[0]); \ - (((char *) g) - ((char *) p)) < get_unaligned_be32(p->length); \ + ((char *) g) < ((char *) p) + get_unaligned_be32(p->length); \ g = (struct rtpg_tpg_dscr *) ( \ ((char *) g) + \ sizeof(struct rtpg_tpg_dscr) + \
multipathd/cli_handlers.c +10 -10
@@ -66,7 +66,7 @@ show_paths (char ** r, int * len, struct vectors * vecs, char * style, c +=snprint_foreign_paths (c, reply + maxlen - c, style, pretty); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -102,7 +102,7 @@ show_path (char ** r, int * len, struct vectors * vecs, struct path *pp, c +=snprint_path (c, reply + maxlen - c, style, pp,0 ); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -131,7 +131,7 @@ show_map_topology (char ** r, int * len, struct multipath * mpp, c = reply; c +=snprint_multipath_topology (c, reply + maxlen - c, mpp,2 ); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -171,7 +171,7 @@ show_maps_topology (char ** r, int * len, struct vectors * vecs) } c +=snprint_foreign_topology (c, reply + maxlen - c,2 ); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -209,7 +209,7 @@ show_maps_json (char ** r, int * len, struct vectors * vecs) c = reply; c +=snprint_multipath_topology_json (c, maxlen, vecs); - again = ((c - reply) == maxlen); + again = (c == reply + maxlen);REALLOC_REPLY (reply, again, maxlen); }
@@ -238,7 +238,7 @@ show_map_json (char ** r, int * len, struct multipath * mpp, c = reply; c +=snprint_multipath_map_json (c, maxlen, mpp); - again = ((c - reply) == maxlen); + again = (c == reply + maxlen);REALLOC_REPLY (reply, again, maxlen); }
@@ -487,7 +487,7 @@ show_map (char ** r, int *len, struct multipath * mpp, char * style, c +=snprint_multipath (c, reply + maxlen - c, style, mpp, pretty); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -533,7 +533,7 @@ show_maps (char ** r, int *len, struct vectors * vecs, char * style, } c +=snprint_foreign_multipaths (c, reply + maxlen - c, style, pretty); - again = ((c - reply) == (maxlen -1 )); + again = (c == reply + maxlen -1 );REALLOC_REPLY (reply, again, maxlen); }
@@ -1297,7 +1297,7 @@ show_blacklist (char ** r, int * len) c = reply; c +=snprint_blacklist_report (conf, c, maxlen); - again = ((c - reply) == maxlen); + again = (c == reply + maxlen);REALLOC_REPLY (reply, again, maxlen); }pthread_cleanup_pop (1 );
@@ -1339,7 +1339,7 @@ show_devices (char ** r, int * len, struct vectors *vecs) c = reply; c +=snprint_devices (conf, c, maxlen, vecs); - again = ((c - reply) == maxlen); + again = (c == reply + maxlen);REALLOC_REPLY (reply, again, maxlen); }pthread_cleanup_pop (1 );
multipathd/main.c +1 -1
@@ -2374,7 +2374,7 @@ checkerloop (void *ap) conf =get_multipath_config (); max_checkint = conf->max_checkint;put_multipath_config (conf); -if (diff_time.tv_sec > max_checkint) +if (diff_time.tv_sec > (time_t )max_checkint) condlog(1, "path checkers took longer " "than %lu seconds, consider " "increasing max_polling_interval",
Signature · 1 line
2.26.2
PATCH 7/11 libmultipath: set_uint: fix parsing for 32bit
In reply to [email protected]From: Martin Wilck <[email protected]>
On architectures where sizeof(long) == sizeof(int), the code wouldn't work as intended. Use strtoul instead. As strtoul happily parses negative numbers as input, require the number to begin with a digit.
--- libmultipath/dict.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
libmultipath/dict.c +7 -4
@@ -60,19 +60,22 @@ static int set_uint(vector strvec, void *ptr) { unsigned int *uint_ptr = (unsigned int *)ptr; -char *buff, *eptr; -long res; +char *buff, *eptr, *p; +unsigned long res;int rc; buff =set_value (strvec);if (!buff)return 1 ; - res =strtol (buff, &eptr,10 ); + p = buff; +while (isspace (*p)) + p++; + res =strtoul (p, &eptr,10 );if (eptr > buff)while (isspace (*eptr)) eptr++; -if (*buff =='\0' || *eptr !='\0' || res <0 || res >UINT_MAX ) { +if (*buff =='\0' || *eptr !='\0' || !isdigit (*p) || res >UINT_MAX ) {condlog (1 ,"%s: invalid value for %s: \"%s\"" , __func__, (char *)VECTOR_SLOT (strvec,0 ), buff); rc =1 ;
Signature · 1 line
2.26.2
PATCH 8/11 multipath-tools tests/Makefile: add -lmpathcmd to LIBDEPS
In reply to [email protected]From: Martin Wilck <[email protected]>
Make sure the linker finds libmpathcmd.
--- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile +1 -1
@@ -10,7 +10,7 @@ W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS) CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \ -Wno-unused-parameter $(W_MISSING_INITIALIZERS) -LIBDEPS += -L$(multipathdir) -lmultipath -lcmocka +LIBDEPS += -L$(multipathdir) -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \ alias directio
Signature · 1 line
2.26.2
PATCH 9/11 multipath tools tests/Makefile: Fix OBJDEPS for hwtable-test
In reply to [email protected]From: Martin Wilck <[email protected]>
OBJDEPS needs to list object files that _call_ functions we want to wrap, but it should _not_ list the object files where these functions are defined; otherwise the linker might resolve these symbols before they can be wrapped.
(Observed on i586 with gcc 9.3.1, ld 2.34.0, where wrapping prio_getprio() doesn't work with prio.o in OBJDEPS).
--- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile +1 -1
@@ -41,7 +41,7 @@ endif dmevents-test_LIBDEPS = -lpthread -ldevmapper -lurcu hwtable-test_TESTDEPS := test-lib.o hwtable-test_OBJDEPS := ../libmultipath/discovery.o ../libmultipath/blacklist.o \ - ../libmultipath/prio.o ../libmultipath/callout.o ../libmultipath/structs.o + ../libmultipath/structs.o hwtable-test_LIBDEPS := -ludev -lpthread -ldl blacklist-test_TESTDEPS := test-log.o blacklist-test_OBJDEPS := ../libmultipath/blacklist.o
Signature · 1 line
2.26.2
PATCH 10/11 multipath-tools tests/test-lib.c: drop __wrap_is_claimed_by_foreign
In reply to [email protected]From: Martin Wilck <[email protected]>
is_claimed_by_foreign() is an inline function and can't be wrapped.
--- tests/test-lib.c | 6 ------ 1 file changed, 6 deletions(-)
tests/test-lib.c +0 -6
@@ -56,12 +56,6 @@ int __wrap_execute_program(char *path, char *value, int len)return 0 ; } -bool __wrap_is_claimed_by_foreign (struct udev_device *ud) -{ -condlog (5 ,"%s: %p" , __func__, ud); -return false; -} -struct udev_list_entry *__wrap_udev_device_get_properties_list_entry (struct udev_device *ud) {
Signature · 1 line
2.26.2
PATCH 11/11 multipath-tools tests/directio: fix -Wmaybe-uninitalized warning
In reply to [email protected]From: Martin Wilck <[email protected]>
Initialize aio_grp to satisfy gcc.
--- tests/directio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/directio.c +1 -1
@@ -316,7 +316,7 @@ static void test_init_free(void **state) {int i, count =0 ;struct checker c[4096 ] = {0 }; -struct aio_group *aio_grp; +struct aio_group *aio_grp =NULL ;assert_true (list_empty (&aio_grp_list));will_return (__wrap_io_setup,0 );
Signature · 1 line
2.26.2
Quoted 10 lines · On Tue, May 12, 2020 at 12:39:20AM +0200, [email protected] wrote:
From: Martin Wilck <[email protected]>
Hi Christophe, hi Ben,
This series fixes a couple of issues I recently found with the 32bit build of multipath-tools, and after integrating our CI into the automated builds on our build server.
Regards
Martin
For the set.
Quoted 30 lines
Martin Wilck (11):
multipath-tools:Makefile: more dependency fixes for parallel build
multipath-tools: Makefile.inc: separate out OPTFLAGS
multipath-tools: Makefile.inc: allow user settings for LDFLAGS
multipath-tools: Makefile.inc: set -Wno-error=clobbered
libmultipath:discovery.c: use %z qualifier forsize_t
libmultipath: eliminate more signed/unsigned comparisons
libmultipath:set_uint: fix parsing for 32bit multipath-tools tests/Makefile: add -lmpathcmd to LIBDEPS multipath tools tests/Makefile: Fix OBJDEPS for hwtable-test multipath-toolstests/test-lib.c: drop__wrap_is_claimed_by_foreignmultipath-tools tests/directio: fix -Wmaybe-uninitalized warningMakefile | 5 +++-- Makefile.inc | 16 ++++++++-------- libmpathpersist/mpath_pr_ioctl.c | 2 +- libmultipath/dict.c | 11 +++++++---- libmultipath/discovery.c | 16 ++++++++-------- libmultipath/print.c | 12 ++++++------ libmultipath/prioritizers/alua_spc3.h | 2 +- multipathd/cli_handlers.c | 20 ++++++++++---------- multipathd/main.c | 2 +- tests/Makefile | 4 ++-- tests/directio.c | 2 +- tests/test-lib.c | 6 ------ 12 files changed, 48 insertions(+), 50 deletions(-)Signature · 1 line
2.26.2