From patchwork Mon Dec 4 03:14:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 10089581 X-Patchwork-Delegate: snitzer@redhat.com 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 3FEBA60327 for ; Mon, 4 Dec 2017 03:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38E76212DB for ; Mon, 4 Dec 2017 03:14:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CF132857E; Mon, 4 Dec 2017 03:14:40 +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 mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D206D212DB for ; Mon, 4 Dec 2017 03:14:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6165C047B62; Mon, 4 Dec 2017 03:14:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A2D36F964; Mon, 4 Dec 2017 03:14:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 519454BB79; Mon, 4 Dec 2017 03:14:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB43EVrE007378 for ; Sun, 3 Dec 2017 22:14:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4238D60FA7; Mon, 4 Dec 2017 03:14:31 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C76B60C8B for ; Mon, 4 Dec 2017 03:14:28 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E6836A7C0 for ; Mon, 4 Dec 2017 03:14:27 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 41828ABEB for ; Mon, 4 Dec 2017 03:14:25 +0000 (UTC) From: Goldwyn Rodrigues To: dm-devel@redhat.com Date: Sun, 3 Dec 2017 21:14:11 -0600 Message-Id: <20171204031412.2435-1-rgoldwyn@suse.de> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 04 Dec 2017 03:14:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 04 Dec 2017 03:14:27 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'rgoldwyn@suse.de' RCPT:'' X-RedHat-Spam-Score: -2.311 (RCVD_IN_DNSWL_MED, SPF_PASS, T_RP_MATCHES_RCVD) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Goldwyn Rodrigues Subject: [dm-devel] [PATCH 1/2] dm-flakey: Use as->argc instead of argc X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 04 Dec 2017 03:14:38 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Goldwyn Rodrigues Since arguments are divided in argument sets, using argc fails corrupt_bio_byte because it is zero. We should be using as->argc to check the number of arguments. Signed-off-by: Goldwyn Rodrigues --- drivers/md/dm-flakey.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index b82cb1ab1eaa..e18c29672a88 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c @@ -105,7 +105,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, * corrupt_bio_byte */ if (!strcasecmp(arg_name, "corrupt_bio_byte")) { - if (!argc) { + if (as->argc < 4) { ti->error = "Feature corrupt_bio_byte requires parameters"; return -EINVAL; } @@ -113,7 +113,6 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); if (r) return r; - argc--; /* * Direction r or w? @@ -127,7 +126,6 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, ti->error = "Invalid corrupt bio direction (r or w)"; return -EINVAL; } - argc--; /* * Value of byte (0-255) to write in place of correct one. @@ -135,7 +133,6 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, r = dm_read_arg(_args + 2, as, &fc->corrupt_bio_value, &ti->error); if (r) return r; - argc--; /* * Only corrupt bios with these flags set. @@ -143,7 +140,6 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, r = dm_read_arg(_args + 3, as, &fc->corrupt_bio_flags, &ti->error); if (r) return r; - argc--; continue; }