From patchwork Wed Mar 15 16:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9626055 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 31EA660522 for ; Wed, 15 Mar 2017 16:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 248FB28554 for ; Wed, 15 Mar 2017 16:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19897285FF; Wed, 15 Mar 2017 16:02:16 +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=-5.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, SUBJ_AS_SEEN 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 9F5B1285AA for ; Wed, 15 Mar 2017 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754116AbdCOQCM (ORCPT ); Wed, 15 Mar 2017 12:02:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50674 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754125AbdCOQAv (ORCPT ); Wed, 15 Mar 2017 12:00:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AB6E80F94 for ; Wed, 15 Mar 2017 16:00:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6AB6E80F94 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jtulak@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6AB6E80F94 Received: from honza-mbp.redhat.com (ovpn-204-198.brq.redhat.com [10.40.204.198]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FG0b8U031509; Wed, 15 Mar 2017 12:00:49 -0400 From: Jan Tulak To: linux-xfs@vger.kernel.org Cc: Jan Tulak Subject: [PATCH 10/22] mkfs: change when to mark an option as seen Date: Wed, 15 Mar 2017 17:00:05 +0100 Message-Id: <20170315160017.27805-11-jtulak@redhat.com> In-Reply-To: <20170315160017.27805-1-jtulak@redhat.com> References: <20170315160017.27805-1-jtulak@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 15 Mar 2017 16:00:50 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the check for seen option more useful for new conflict detection by moving it's logic to new place - we are no longer doing the respecification as before. Signed-off-by: Jan Tulak --- mkfs/xfs_mkfs.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index c3ab9221..db82a528 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -152,10 +152,6 @@ unsigned int sectorsize; * Do not set this flag when definning a subopt. It is used to remeber that * this subopt was already seen, for example for conflicts detection. * - * str_seen INTERNAL - * Do not set. It is used internally for respecification, when some options - * has to be parsed twice - at first as a string, then later as a number. - * * convert OPTIONAL * A flag signalling whether the user-given value can use suffixes. * If you want to allow the use of user-friendly values like 13k, 42G, @@ -212,7 +208,6 @@ struct opt_params { struct subopt_param { int index; bool seen; - bool str_seen; bool convert; bool is_power_2; struct subopt_conflict { @@ -1375,7 +1370,7 @@ static void check_subopt_conflicts( struct opt_params *opt, int index, - bool str_seen) + bool seen) { struct subopt_param *sp = &opt->subopt_params[index]; int i; @@ -1387,23 +1382,6 @@ check_subopt_conflicts( reqval(opt->name, (char **)opt->subopts, index); } - /* - * Check for respecification of the option. This is more complex than it - * seems because some options are parsed twice - once as a string during - * input parsing, then later the string is passed to getnum for - * conversion into a number and bounds checking. Hence the two variables - * used to track the different uses based on the @str parameter passed - * to us. - */ - if (!str_seen) { - if (sp->seen) - respec(opt->name, (char **)opt->subopts, index); - sp->seen = true; - } else { - if (sp->str_seen) - respec(opt->name, (char **)opt->subopts, index); - sp->str_seen = true; - } /* check for conflicts with the option */ for (i = 0; i < MAX_CONFLICTS; i++) { @@ -1413,8 +1391,7 @@ check_subopt_conflicts( break; if (conflict_opt.test_values) break; - if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen || - opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) { + if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen) { conflict_struct(opt, sp, &conflict_opt); } } @@ -1440,8 +1417,7 @@ check_subopt_value( break; if (!conflict_opt.test_values) break; - if ((opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen || - opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) && + if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen && opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].value == conflict_opt.invalid_value && value == conflict_opt.at_value) { @@ -1462,7 +1438,11 @@ check_opt( int index; struct opt_params *opt = &opts[opti]; for (index = 0; index < MAX_SUBOPTS; index++) { + if (opt->subopts[index] == NULL) + break; struct subopt_param *sp = &opt->subopt_params[index]; + if (!sp->seen) + continue; check_subopt_conflicts(opt, index, false); check_subopt_value(opt, index, sp->value); } @@ -1489,9 +1469,12 @@ getnum( if (!str || *str == '\0') { if (sp->defaultval == SUBOPT_NEEDS_VAL) reqval(opts->name, (char **)opts->subopts, index); + sp->seen = true; return sp->defaultval; } + sp->seen = true; + if (sp->minval == 0 && sp->maxval == 0) { fprintf(stderr, _("Option -%c %s has undefined minval/maxval." @@ -1540,11 +1523,10 @@ getstr( struct opt_params *opts, int index) { - check_subopt_conflicts(opts, index, true); - /* empty strings for string options are not valid */ if (!str || *str == '\0') reqval(opts->name, (char **)opts->subopts, index); + opts->subopt_params[index].seen = true; return str; }