From patchwork Thu May 4 07:31:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9710905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE5C660362 for ; Thu, 4 May 2017 07:31:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A149F28682 for ; Thu, 4 May 2017 07:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 962E828685; Thu, 4 May 2017 07:31:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29BB328682 for ; Thu, 4 May 2017 07:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752498AbdEDHbr (ORCPT ); Thu, 4 May 2017 03:31:47 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35582 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751485AbdEDHbr (ORCPT ); Thu, 4 May 2017 03:31:47 -0400 Received: by mail-pf0-f172.google.com with SMTP id v14so3724617pfd.2 for ; Thu, 04 May 2017 00:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=DVp5CLa+2MTGrI9hAiCN3oXvkThaelb2Fce2+iZ7hS4=; b=qj8TKRI165TUb1HEqU4c5phQEWvsXlQTofgy0n1Iu+OHHkg8kaCP8cWgAepld8rQuQ rN458k7o98/03IToeASDB6CHKCf7IPyvsTBJvqtrdQiOttIZWRLLbfgTO5Iaq/pOMACU RHxFNdmp+tynOHfYdIFP3GAJbxb5bg2eXgd9+q+hKgtHV5RbUIn7jM/GcLl5T+Pk9nug 6F5/9qk7xZlXNgFfvn4hn1dCe1up9wWiQkS4kJkF74hIzNHg0H91zQQh+sKhKkm0A1tF uZH2Ow1ObHH5R4LGijLJOpNSYFQKA1P/tSTiOZngO1rYw56VwHysOK1TQTeiAKcj07qi eNEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=DVp5CLa+2MTGrI9hAiCN3oXvkThaelb2Fce2+iZ7hS4=; b=mxRySHFET8pH5K86nRPajAML686bIx8Kj7eN2MJQHRMN4mun4VAmURgjxwqx2R4bBW ohsb8IqT62tYX0g0hbEchelil0V93aKwAvBi/0nTyCl/FzgdDlnnxFgLfC2Kv/u7R1Fk yY25r8+Fo/prK7SpOZ4AakwTKmf2x8Pdd2Bn1sxUVcahfVjkmB9T9goy4Ka7KbZyXKie waHgMA4N89UlMSHDGip5P4nWi5e6B+MW6shP3MuqJ0lIFw7zKYZz+9U1OQ+bMfp72lKV BrnKejIk+1maJdrRzga+5/ecpQYHHq3BsqnBEV+ikxEPSZex+GkNS5rmvuF1EBu11Cfc Jk3g== X-Gm-Message-State: AN3rC/6W2HDLaMddHibe8ZBjL3GzSrpoRTnCrhK1QhOtk2Cka7KSfJag VSZgv5rw642rcFbJ X-Received: by 10.84.179.65 with SMTP id a59mr52774933plc.171.1493883106399; Thu, 04 May 2017 00:31:46 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:1d23]) by smtp.gmail.com with ESMTPSA id q6sm2272168pfq.18.2017.05.04.00.31.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 May 2017 00:31:45 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: Bart Van Assche , kernel-team@fb.com Subject: [PATCH v2 04/12] blk-mq-debugfs: don't open code strstrip() Date: Thu, 4 May 2017 00:31:26 -0700 Message-Id: <65b6e5cb3c0be1eaa543a38e47512c2f45a0ace1.1493882751.git.osandov@fb.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Slightly more readable, plus we also strip leading spaces. Signed-off-by: Omar Sandoval Reviewed-by: Hannes Reinecke --- 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) {