Skip to contentSkip to conversation

Clang fixes

PATCH In review Hannes Reinecke 2 participants 5 messages Aug 9, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

cover Clang fixes

Hi Christophe,

Xose found some issues when building with clang.

Hannes Reinecke (3):
libmultipath/discovery.c: use 'unsigned long' instead of 'unsigned int' libmultipath/parser.c: correctly terminate buffer
multipath: fixup check for out-of-scope maps

 libmultipath/discovery.c | 2 +-
 libmultipath/parser.c    | 2 +-
 multipath/main.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.6.6
#1 lore raw

PATCH 1/3 libmultipath/discovery.c: use 'unsigned long' instead of 'unsigned int'

We should be using 'unsigned long' for the variable preferred.

---
 libmultipath/discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/discovery.c +1 -1
index 1fb4db4..38ab038 100644
@@ -491,7 +491,7 @@ sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen)
 {
 	struct udev_device *parent = pp->udev;
 	char value[16], *eptr;
-	unsigned int preferred;
+	unsigned long preferred;
 
 	while (parent) {
 		const char *subsys = udev_device_get_subsystem(parent);
Signature · 1 line
2.6.6
#2 lore raw

PATCH 2/3 libmultipath/parser.c: correctly terminate buffer

In reply to Hannes Reinecke

The code would be returning a static NULL buffer instead of terminating the original buffer.

---
 libmultipath/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/parser.c +1 -1
index dd955f3..c47d891 100644
@@ -171,7 +171,7 @@ snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw, void *data)
 			r = kw->print(conf, buff + fwd, len - fwd, data);
 			put_multipath_config(conf);
 			if (!r) { /* no output if no value */
-				buff = '\0';
+				buff[0] = '\0';
 				return 0;
 			}
 			fwd += r;
Signature · 1 line
2.6.6
#3 lore raw

PATCH 3/3 multipath: fixup check for out-of-scope maps

In reply to Hannes Reinecke

The 'wwid' in struct multipath is a static array, so a check for the existence of 'wwid' is pointless. We should rather check if the argument 'refwwid' is not NULL and has a length larger then '0'.

---
 multipath/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/main.c +1 -1
index 93376a9..ee00fdbd 100644
@@ -212,7 +212,7 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)
 		/*
 		 * discard out of scope maps
 		 */
-		if (mpp->wwid && refwwid &&
+		if (refwwid && strlen(refwwid) &&
 		    strncmp(mpp->wwid, refwwid, WWID_SIZE)) {
 			condlog(3, "skip map %s: out of scope", mpp->alias);
 			free_multipath(mpp, KEEP_PATHS);
Signature · 1 line
2.6.6
#4 lore raw
In reply to Hannes Reinecke

Merged.
Thanks.

Quoted 18 lines · Hannes Reinecke

Hi Christophe,

Xose found some issues when building with clang.

Hannes Reinecke (3):
libmultipath/discovery.c: use 'unsigned long' instead of 'unsigned int' libmultipath/parser.c: correctly terminate buffer
multipath: fixup check for out-of-scope maps

 libmultipath/discovery.c | 2 +-
 libmultipath/parser.c    | 2 +-
 multipath/main.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--
2.6.6