Message ID | 65b6e5cb3c0be1eaa543a38e47512c2f45a0ace1.1493882751.git.osandov@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 05/04/2017 09:31 AM, Omar Sandoval wrote: > From: Omar Sandoval <osandov@fb.com> > > Slightly more readable, plus we also strip leading spaces. > > Signed-off-by: Omar Sandoval <osandov@fb.com> > --- > block/blk-mq-debugfs.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > Reviewed-by: Hannes Reinecke <hare@suse.com> Cheers, Hannes
On Thu, 2017-05-04 at 00:31 -0700, Omar Sandoval wrote: > From: Omar Sandoval <osandov@fb.com> > > Slightly more readable, plus we also strip leading spaces. > > Signed-off-by: Omar Sandoval <osandov@fb.com> > --- > block/blk-mq-debugfs.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c > index 2a19237455d4..109ae9f3d400 100644 > --- a/block/blk-mq-debugfs.c > +++ b/block/blk-mq-debugfs.c > @@ -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) { Hello Omar, Sorry but in my opinion the value of this patch is so small that I'm not sure it's worth to merge this patch. Bart.
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 2a19237455d4..109ae9f3d400 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -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) {