public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH cosmetic] Remove trailing newline in elevator switch error message
@ 2017-04-29  5:38 Markus Trippelsdorf
  2017-05-01 15:18 ` Bart Van Assche
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Trippelsdorf @ 2017-04-29  5:38 UTC (permalink / raw)
  To: linux-block

Trying to switch to a non-existing elevator currently results in garbled
dmesg output, e.g.:

 # echo "foo" > /sys/block/sda/queue/scheduler 

elevator: type foo not found
elevator: switch to foo
 failed

(note the unintended line break.)

Fix by stripping the trailing newline.

diff --git a/block/elevator.c b/block/elevator.c
index bf11e70f008b..4f13fcd3c626 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1112,6 +1112,7 @@ static inline bool elv_support_iosched(struct request_queue *q)
 ssize_t elv_iosched_store(struct request_queue *q, const char *name,
 			  size_t count)
 {
+	char elevator_name[ELV_NAME_MAX];
 	int ret;
 
 	if (!(q->mq_ops || q->request_fn) || !elv_support_iosched(q))
@@ -1121,7 +1122,9 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
 	if (!ret)
 		return count;
 
-	printk(KERN_ERR "elevator: switch to %s failed\n", name);
+	strlcpy(elevator_name, name, sizeof(elevator_name));
+	strstrip(elevator_name);
+	printk(KERN_ERR "elevator: switch to %s failed\n", elevator_name);
 	return ret;
 }
 
-- 
Markus

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-06  5:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-29  5:38 [PATCH cosmetic] Remove trailing newline in elevator switch error message Markus Trippelsdorf
2017-05-01 15:18 ` Bart Van Assche
2017-05-01 15:49   ` markus
2017-05-01 15:58     ` Bart Van Assche
2017-05-01 16:29       ` [PATCH v2 " markus
2017-05-05 20:05         ` Bart Van Assche
2017-05-06  5:15           ` markus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox