diff mbox

[09/22] mkfs: change conflict checks to utilize the new conflict structure

Message ID 1481117249-21273-10-git-send-email-jtulak@redhat.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Jan Tulak Dec. 7, 2016, 1:27 p.m. UTC
Bring the conflicts detection up to date with conflicts declaration.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)

Comments

Bill O'Donnell Jan. 13, 2017, 5:08 p.m. UTC | #1
On Wed, Dec 07, 2016 at 02:27:16PM +0100, Jan Tulak wrote:
> Bring the conflicts detection up to date with conflicts declaration.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

There's a missing definition for check_subopt()
FWIW, I see the call gets removed in patch10.

> ---
>  mkfs/xfs_mkfs.c | 37 +++++++++++++++++++++++++++++++------
>  1 file changed, 31 insertions(+), 6 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 30618ff..d11fad6 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1372,7 +1372,7 @@ illegal_option(
>   * Check for conflicts and option respecification.
>   */
>  static void
> -check_opt(
> +check_subopt_conflicts(
>  	struct opt_params	*opt,
>  	int			index,
>  	bool			str_seen)
> @@ -1424,7 +1424,7 @@ check_opt(
>   * Check for conflict values between options.
>   */
>  static void
> -check_opt_value(
> +check_subopt_value(
>  	struct opt_params	*opt,
>  	int			index,
>  	long long 		value)
> @@ -1450,6 +1450,32 @@ check_opt_value(
>  	}
>  }
>  
> +/**
> + * Go through entire opt_params table and check every option for valid values
> + * and for conflicts.
> + */
> +static void
> +check_opt(
> +	struct opt_params *opts,
> +	int opti)
> +{
> +	int index;
> +	struct opt_params *opt = &opts[opti];
> +	for (index = 0; index < MAX_SUBOPTS; index++) {
> +		struct subopt_param *sp = &opt->subopt_params[index];
> +		check_subopt_conflicts(opt, index, false);
> +		check_subopt_value(opt, index, sp->value);
> +	}
> +}
> +static void
> +check_all_opts(struct opt_params *opts)
> +{
> +	int opti;
> +	for (opti = 0; opti < MAX_OPTS; opti++) {
> +		check_opt(opts, opti);
> +	}
> +}
> +
>  static long long
>  getnum(
>  	const char		*str,
> @@ -1459,7 +1485,6 @@ getnum(
>  	struct subopt_param	*sp = &opts->subopt_params[index];
>  	long long		c;
>  
> -	check_opt(opts, index, false);
>  	/* empty strings might just return a default value */
>  	if (!str || *str == '\0') {
>  		if (sp->defaultval == SUBOPT_NEEDS_VAL)
> @@ -1493,8 +1518,6 @@ getnum(
>  			illegal_option(str, opts, index, NULL);
>  	}
>  
> -	check_opt_value(opts, index, c);
> -
>  	/* Validity check the result. */
>  	if (c < sp->minval)
>  		illegal_option(str, opts, index, _("value is too small"));
> @@ -1517,7 +1540,7 @@ getstr(
>  	struct opt_params	*opts,
>  	int			index)
>  {
> -	check_opt(opts, index, true);
> +	check_subopt(opts, index, true);

check_subopt is undefined. ^^^

>  
>  	/* empty strings for string options are not valid */
>  	if (!str || *str == '\0')
> @@ -2213,6 +2236,8 @@ main(
>  	} else
>  		dfile = xi.dname;
>  
> +	check_all_opts(opts);
> +
>  	/*
>  	 * Blocksize and sectorsize first, other things depend on them
>  	 * For RAID4/5/6 we want to align sector size and block size,
> -- 
> 2.8.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Tulak Jan. 16, 2017, 12:42 p.m. UTC | #2
On Fri, Jan 13, 2017 at 6:08 PM, Bill O'Donnell <billodo@redhat.com> wrote:
> On Wed, Dec 07, 2016 at 02:27:16PM +0100, Jan Tulak wrote:
>> Bring the conflicts detection up to date with conflicts declaration.
>>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
>
> There's a missing definition for check_subopt()
> FWIW, I see the call gets removed in patch10.
>
>> ---
>>  mkfs/xfs_mkfs.c | 37 +++++++++++++++++++++++++++++++------
>>  1 file changed, 31 insertions(+), 6 deletions(-)
>>
>> [snip...]
>>
>> @@ -1517,7 +1540,7 @@ getstr(
>>       struct opt_params       *opts,
>>       int                     index)
>>  {
>> -     check_opt(opts, index, true);
>> +     check_subopt(opts, index, true);
>
> check_subopt is undefined. ^^^

Should be renamed to check_subopt_conflicts here, even if it is
deleted in the next patch.
diff mbox

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 30618ff..d11fad6 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1372,7 +1372,7 @@  illegal_option(
  * Check for conflicts and option respecification.
  */
 static void
-check_opt(
+check_subopt_conflicts(
 	struct opt_params	*opt,
 	int			index,
 	bool			str_seen)
@@ -1424,7 +1424,7 @@  check_opt(
  * Check for conflict values between options.
  */
 static void
-check_opt_value(
+check_subopt_value(
 	struct opt_params	*opt,
 	int			index,
 	long long 		value)
@@ -1450,6 +1450,32 @@  check_opt_value(
 	}
 }
 
+/**
+ * Go through entire opt_params table and check every option for valid values
+ * and for conflicts.
+ */
+static void
+check_opt(
+	struct opt_params *opts,
+	int opti)
+{
+	int index;
+	struct opt_params *opt = &opts[opti];
+	for (index = 0; index < MAX_SUBOPTS; index++) {
+		struct subopt_param *sp = &opt->subopt_params[index];
+		check_subopt_conflicts(opt, index, false);
+		check_subopt_value(opt, index, sp->value);
+	}
+}
+static void
+check_all_opts(struct opt_params *opts)
+{
+	int opti;
+	for (opti = 0; opti < MAX_OPTS; opti++) {
+		check_opt(opts, opti);
+	}
+}
+
 static long long
 getnum(
 	const char		*str,
@@ -1459,7 +1485,6 @@  getnum(
 	struct subopt_param	*sp = &opts->subopt_params[index];
 	long long		c;
 
-	check_opt(opts, index, false);
 	/* empty strings might just return a default value */
 	if (!str || *str == '\0') {
 		if (sp->defaultval == SUBOPT_NEEDS_VAL)
@@ -1493,8 +1518,6 @@  getnum(
 			illegal_option(str, opts, index, NULL);
 	}
 
-	check_opt_value(opts, index, c);
-
 	/* Validity check the result. */
 	if (c < sp->minval)
 		illegal_option(str, opts, index, _("value is too small"));
@@ -1517,7 +1540,7 @@  getstr(
 	struct opt_params	*opts,
 	int			index)
 {
-	check_opt(opts, index, true);
+	check_subopt(opts, index, true);
 
 	/* empty strings for string options are not valid */
 	if (!str || *str == '\0')
@@ -2213,6 +2236,8 @@  main(
 	} else
 		dfile = xi.dname;
 
+	check_all_opts(opts);
+
 	/*
 	 * Blocksize and sectorsize first, other things depend on them
 	 * For RAID4/5/6 we want to align sector size and block size,