From: Jan Tulak <jtulak@redhat.com>
To: linux-xfs@vger.kernel.org
Cc: Jan Tulak <jtulak@redhat.com>
Subject: [PATCH 10/22] mkfs: change when to mark an option as seen
Date: Wed, 7 Dec 2016 14:27:17 +0100 [thread overview]
Message-ID: <1481117249-21273-11-git-send-email-jtulak@redhat.com> (raw)
In-Reply-To: <1481117249-21273-1-git-send-email-jtulak@redhat.com>
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 <jtulak@redhat.com>
---
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 d11fad6..b3625ed 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(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;
}
--
2.8.1
next prev parent reply other threads:[~2016-12-07 13:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-07 13:27 [RFC PATCH 00/22] mkfs.xfs: Make stronger conflict checks Jan Tulak
2016-12-07 13:27 ` [PATCH 01/22] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2017-01-13 16:56 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 02/22] mkfs: merge tables for opts parsing into one table Jan Tulak
2017-01-13 16:57 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 03/22] mkfs: extend opt_params with a value field Jan Tulak
2017-01-13 16:55 ` Bill O'Donnell
2017-01-16 12:42 ` Jan Tulak
2016-12-07 13:27 ` [PATCH 04/22] mkfs: change conflicts array into a table capable of cross-option addressing Jan Tulak
2017-01-13 17:56 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 05/22] mkfs: add a check for conflicting values Jan Tulak
2017-01-13 17:58 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 06/22] mkfs: add cross-section conflict checks Jan Tulak
2017-01-13 21:18 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 07/22] mkfs: Move opts related #define to one place Jan Tulak
2017-01-13 21:19 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 08/22] mkfs: move conflicts into the table Jan Tulak
2017-01-13 21:20 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 09/22] mkfs: change conflict checks to utilize the new conflict structure Jan Tulak
2017-01-13 17:08 ` Bill O'Donnell
2017-01-16 12:42 ` Jan Tulak
2016-12-07 13:27 ` Jan Tulak [this message]
2017-01-13 21:20 ` [PATCH 10/22] mkfs: change when to mark an option as seen Bill O'Donnell
2016-12-07 13:27 ` [PATCH 11/22] mkfs: add test_default_value into conflict struct Jan Tulak
2017-01-13 21:21 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 12/22] mkfs: expand conflicts declarations to named declaration Jan Tulak
2017-01-13 17:21 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 13/22] mkfs: remove zeroed items from conflicts declaration Jan Tulak
2017-01-16 14:13 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 14/22] mkfs: rename defaultval to flagval in opts Jan Tulak
2017-01-16 14:14 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 15/22] mkfs: replace SUBOPT_NEEDS_VAL for a flag Jan Tulak
2017-01-16 14:14 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 16/22] mkfs: Change all value fields in opt structures into unions Jan Tulak
2017-01-13 17:36 ` Bill O'Donnell
2017-01-16 12:44 ` Jan Tulak
2016-12-07 13:27 ` [PATCH 17/22] mkfs: use old variables as pointers to the new opts struct values Jan Tulak
2017-01-13 17:43 ` Bill O'Donnell
2017-01-16 12:45 ` Jan Tulak
2016-12-07 13:27 ` [PATCH 18/22] mkfs: prevent sector/blocksize to be specified as a number of blocks Jan Tulak
2017-01-16 14:15 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 19/22] mkfs: subopt flags should be saved as bool Jan Tulak
2017-01-16 14:16 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 20/22] mkfs: move uuid empty string test to getstr() Jan Tulak
2017-01-16 14:16 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 21/22] mkfs: remove duplicit checks Jan Tulak
2017-01-16 14:17 ` Bill O'Donnell
2016-12-07 13:27 ` [PATCH 22/22] mkfs: prevent multiple specifications of a single option Jan Tulak
2017-01-16 14:18 ` Bill O'Donnell
2017-01-06 11:42 ` [RFC PATCH 00/22] mkfs.xfs: Make stronger conflict checks Jan Tulak
2017-01-09 19:43 ` Eric Sandeen
2017-01-10 9:47 ` Jan Tulak
2017-01-12 15:46 ` Bill O'Donnell
2017-01-16 20:14 ` Bill O'Donnell
-- strict thread matches above, loose matches on Subject: below --
2017-03-15 15:59 [PATCH " Jan Tulak
2017-03-15 16:00 ` [PATCH 10/22] mkfs: change when to mark an option as seen Jan Tulak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481117249-21273-11-git-send-email-jtulak@redhat.com \
--to=jtulak@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).