Skip to content

Commit

Permalink
blk-mq-debugfs: don't open code strstrip()
Browse files Browse the repository at this point in the history
Slightly more readable, plus we also strip leading spaces.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
osandov authored and axboe committed May 4, 2017
1 parent c7e4145 commit 71b9051
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions block/blk-mq-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,16 @@ static ssize_t blk_queue_flags_store(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct request_queue *q = file_inode(file)->i_private;
char op[16] = { }, *s;
char opbuf[16] = { }, *op;

if (count >= sizeof(op)) {
if (count >= sizeof(opbuf)) {
pr_err("%s: operation too long\n", __func__);
goto inval;
}

if (copy_from_user(op, buf, count))
if (copy_from_user(opbuf, buf, count))
return -EFAULT;
s = op;
strsep(&s, " \t\n"); /* strip trailing whitespace */
op = strstrip(opbuf);
if (strcmp(op, "run") == 0) {
blk_mq_run_hw_queues(q, true);
} else if (strcmp(op, "start") == 0) {
Expand Down

0 comments on commit 71b9051

Please sign in to comment.