From: "markus@trippelsdorf.de" <markus@trippelsdorf.de>
To: Bart Van Assche <Bart.VanAssche@sandisk.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v2 cosmetic] Remove trailing newline in elevator switch error message
Date: Mon, 1 May 2017 18:29:28 +0200 [thread overview]
Message-ID: <20170501162928.GB291@x4> (raw)
In-Reply-To: <1493654279.2665.5.camel@sandisk.com>
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.
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
diff --git a/block/elevator.c b/block/elevator.c
index bf11e70f008b..1af23eee4395 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1054,7 +1054,6 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
*/
static int __elevator_change(struct request_queue *q, const char *name)
{
- char elevator_name[ELV_NAME_MAX];
struct elevator_type *e;
/*
@@ -1063,15 +1062,14 @@ static int __elevator_change(struct request_queue *q, const char *name)
if (q->mq_ops && !strncmp(name, "none", 4))
return elevator_switch(q, NULL);
- strlcpy(elevator_name, name, sizeof(elevator_name));
- e = elevator_get(strstrip(elevator_name), true);
+ e = elevator_get(name, true);
if (!e) {
- printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
+ printk(KERN_ERR "elevator: type %s not found\n", name);
return -EINVAL;
}
if (q->elevator &&
- !strcmp(elevator_name, q->elevator->type->elevator_name)) {
+ !strcmp(name, q->elevator->type->elevator_name)) {
elevator_put(e);
return 0;
}
@@ -1112,16 +1110,19 @@ 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))
return count;
- ret = __elevator_change(q, name);
+ strlcpy(elevator_name, name, sizeof(elevator_name));
+ strstrip(elevator_name);
+ ret = __elevator_change(q, elevator_name);
if (!ret)
return count;
- printk(KERN_ERR "elevator: switch to %s failed\n", name);
+ printk(KERN_ERR "elevator: switch to %s failed\n", elevator_name);
return ret;
}
--
Markus
next prev parent reply other threads:[~2017-05-01 16:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` markus [this message]
2017-05-05 20:05 ` [PATCH v2 " Bart Van Assche
2017-05-06 5:15 ` markus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170501162928.GB291@x4 \
--to=markus@trippelsdorf.de \
--cc=Bart.VanAssche@sandisk.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.