From patchwork Sun Jan 22 08:31:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9530829 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 8F9236020B for ; Sun, 22 Jan 2017 08:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 811DF1FF1E for ; Sun, 22 Jan 2017 08:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7274927E5A; Sun, 22 Jan 2017 08:31:35 +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,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 24BBE1FF1E for ; Sun, 22 Jan 2017 08:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751065AbdAVIbe (ORCPT ); Sun, 22 Jan 2017 03:31:34 -0500 Received: from mout.web.de ([212.227.15.3]:53751 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbdAVIbd (ORCPT ); Sun, 22 Jan 2017 03:31:33 -0500 Received: from [192.168.1.2] ([78.48.136.24]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lgpcs-1c8mpz3vC2-00oIRI; Sun, 22 Jan 2017 09:31:30 +0100 Subject: [PATCH 1/5] blk-throttle: Move three assignments for the variable "ret" in tg_set_max() To: linux-block@vger.kernel.org, Jens Axboe References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <75495d45-cfc4-9740-39e4-bd4c3e71232b@users.sourceforge.net> Date: Sun, 22 Jan 2017 09:31:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:3Pf+0kDGWzQzxl8fUnV8CdL83/SHlhSZPEqMvTwTDYD46cKnwcT WkI6MuM+vGXKnsAZR4CdDcjSr+FKC56RZLIy9eMhX/WKHpNRVJRWTz2rGPuCG7DgzZERdnl ua/M6t9cNz/zRwfAj+fG+7QG2Wqo6ilKo96PS4o9TutBnNFS9j9IsDsibxX9lScZ+3AMiGy QOXjyAV85TX8FULLKqhKQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:sXLV79gSo4I=:2CbWMxWrjOrdsNKrH9jqJ1 ecuzb/5ICYMTMgcXzkcXuDlu8+PW3XR5k/wroD2EsxhEhvcUeuaqW88HvRXNlGsKFP5wTmSos gmXWt+JeZeHYO3c+eO3jjdTSxaRBwF1qVZ/c8N6q1z4Zr+u1G60pm7vbjEyL0CqbOpaCV+7m/ rxzP0loTr4AXvROT0nCDfTt1QmmbkMP15cYpaxh265lRq7HRbQRR4Hgsyi1CgbrmXnP2WB9Fi yyGAgxpJbWpjlHfC0xpj89HgH26i0W7+6RyP2iR0Q8FdmDNHWthBE8UK59IknWoub5/BktTk0 1oXF6OOufWbqWtfyX8uTrJ3ze/CRL/2777oEU+d5OpC7dIuA3/CeQKdG7gCaqWgfYi5R0DrVh x73OM7W29m9XGoXK/tT0YGsmDt6H/dd0InOHiX1KKEbOBElvCTH5rp9FLUpz6SRGPg2OxoDLf WZMSXcOBWwd0yJVowfHf/J7fmk+wQkrEOS6qwvgQHbEJ71+1Eh2L4QcBdh7D/DdzO67L4rbNj M07dxfS+t3k4B4wLijHpWYjCFBk6EyoZ1rLI3gPrzlyBA0Hj/xVy+5pkS04H9VU1o88fVAM3y 2FVojsW//mi5rz/dnI1OHYRyNOrq2IXc+FXVmtHJz7fkBW7zpUNFBlew2NU+bDFG/CoIo70Ko nW3Pgb/4qI6G12bDg/hzNEeJFMA+kklfWoluSCk8rQ7eqiG5VbQciRm+xZi5cBBBIubSaJDm7 0Mn38HuiCyQpSVxdQ1K2nbE0uONqx5P2vKKr9V9wlZF7/TQ5vbdwPfmZYXCBcx8FCgnsFhD5N BN6ORPy 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: Markus Elfring Date: Sat, 21 Jan 2017 21:23:06 +0100 A local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a software failure there. Signed-off-by: Markus Elfring --- block/blk-throttle.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 6f4c96e5f86b..51d112deb02e 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1327,27 +1327,30 @@ static ssize_t tg_set_max(struct kernfs_open_file *of, break; ctx.body += len; - ret = -EINVAL; p = tok; strsep(&p, "="); - if (!p || (sscanf(p, "%llu", &val) != 1 && strcmp(p, "max"))) + if (!p || (sscanf(p, "%llu", &val) != 1 && strcmp(p, "max"))) { + ret = -EINVAL; goto out_finish; + } - ret = -ERANGE; - if (!val) + if (!val) { + ret = -ERANGE; goto out_finish; + } - ret = -EINVAL; - if (!strcmp(tok, "rbps")) + if (!strcmp(tok, "rbps")) { v[0] = val; - else if (!strcmp(tok, "wbps")) + } else if (!strcmp(tok, "wbps")) { v[1] = val; - else if (!strcmp(tok, "riops")) + } else if (!strcmp(tok, "riops")) { v[2] = min_t(u64, val, UINT_MAX); - else if (!strcmp(tok, "wiops")) + } else if (!strcmp(tok, "wiops")) { v[3] = min_t(u64, val, UINT_MAX); - else + } else { + ret = -EINVAL; goto out_finish; + } } tg->bps[READ] = v[0];