Skip to contentSkip to conversation

md-multipath: Replace a seq_printf() call by seq_putc() in multipath_status()

PATCH In review Markus Elfring 2 participants 3 messages Jul 1, 2019 – Jul 3, 2019

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

PATCH 1/1 md-multipath: Replace a seq_printf() call by seq_putc() in multipath_status()

From: Markus Elfring <[email protected]>
Date: Mon, 1 Jul 2019 13:07:55 +0200

A single character (depending on a condition check) should be put into a sequence. Thus use the corresponding function “seq_putc”.

This issue was detected by using the Coccinelle software.

---
 drivers/md/md-multipath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md-multipath.c +2 -1
index 6780938d2991..3bf6f97ea264 100644
@@ -146,7 +146,8 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
 	rcu_read_lock();
 	for (i = 0; i < conf->raid_disks; i++) {
 		struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev);
-		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
+		seq_putc(seq,
+			 rdev && test_bit(In_sync, &rdev->flags) ? 'U' : '_');
 	}
 	rcu_read_unlock();
 	seq_putc(seq, ']');

--
2.22.0

#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 1 Jul 2019 13:07:55 +0200

A single character (depending on a condition check) should be put into a sequence. Thus use the corresponding function “seq_putc”.

This issue was detected by using the Coccinelle software.

Can you explain why this is necessary?

Thanks,
Song

#2 lore raw
Quoted 2 lines
Quoted 2 lines

A single character (depending on a condition check) should be put into a sequence. Thus use the corresponding function “seq_putc”.

…

Quoted 1 line

Can you explain why this is necessary?

I suggest another bit of software fine-tuning.

* Pass only a relevant character instead of a string.

* Omit the format string for a function parameter.

Regards,
Markus