[2/4] btrfs-progs: fix a reression that "property" with -t option doesn't work
diff mbox

Message ID 56E601F4.9070908@jp.fujitsu.com
State New
Headers show

Commit Message

Satoru Takeuchi March 14, 2016, 12:12 a.m. UTC
"property" is considered as working without any options
from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

However, we can pass -t option to this command.

* actual result

  ==================================================
  # ./btrfs prop list -t f /btrfs
  btrfs property list: invalid option -- 't'
  usage: btrfs property list [-t <type>] <object>

      Lists available properties with their descriptions for the given object.

      Please see the help of 'btrfs property get' for a description of
      objects and object types.
  ==================================================

* expected result

  ==================================================
  # btrfs prop list -t f /btrfs
  label               Set/get label of device
  ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
 cmds-property.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

David Sterba March 14, 2016, 12:23 p.m. UTC | #1
On Mon, Mar 14, 2016 at 09:12:36AM +0900, Satoru Takeuchi wrote:
> --- a/cmds-property.c
> +++ b/cmds-property.c
> @@ -379,9 +379,7 @@ static int cmd_property_get(int argc, char **argv)
>  	char *name = NULL;
>  	int types = 0;
> 
> -	clean_args_no_options(argc, argv, cmd_property_get_usage);
> -
> -	if (check_argc_min(argc, 2) || check_argc_max(argc, 5))
> +	if (check_argc_min(argc, 2))
>  		usage(cmd_property_get_usage);
> 
>  	parse_args(argc, argv, cmd_property_get_usage, &types, &object, &name,

We still need to check the number of non-option arguments here, when the
optind is set from parse_args.

> @@ -415,9 +413,7 @@ static int cmd_property_set(int argc, char **argv)
> -	if (check_argc_min(argc, 4) || check_argc_max(argc, 6))
> +	if (check_argc_min(argc, 4))
>  		usage(cmd_property_set_usage);

...

>  	parse_args(argc, argv, cmd_property_set_usage, &types,
> @@ -446,9 +442,7 @@ static int cmd_property_list(int argc, char **argv)
> -	if (check_argc_min(argc, 2) || check_argc_max(argc, 4))
> +	if (check_argc_min(argc, 2))

...
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Satoru Takeuchi March 15, 2016, 11:28 p.m. UTC | #2
On 2016/03/14 21:23, David Sterba wrote:
> On Mon, Mar 14, 2016 at 09:12:36AM +0900, Satoru Takeuchi wrote:
>> --- a/cmds-property.c
>> +++ b/cmds-property.c
>> @@ -379,9 +379,7 @@ static int cmd_property_get(int argc, char **argv)
>>   	char *name = NULL;
>>   	int types = 0;
>>
>> -	clean_args_no_options(argc, argv, cmd_property_get_usage);
>> -
>> -	if (check_argc_min(argc, 2) || check_argc_max(argc, 5))
>> +	if (check_argc_min(argc, 2))
>>   		usage(cmd_property_get_usage);
>>
>>   	parse_args(argc, argv, cmd_property_get_usage, &types, &object, &name,
>
> We still need to check the number of non-option arguments here, when the
> optind is set from parse_args.

OK, I'll send a patch which checks the number after getopt.

Thanks,
Satoru

>
>> @@ -415,9 +413,7 @@ static int cmd_property_set(int argc, char **argv)
>> -	if (check_argc_min(argc, 4) || check_argc_max(argc, 6))
>> +	if (check_argc_min(argc, 4))
>>   		usage(cmd_property_set_usage);
>
> ...
>
>>   	parse_args(argc, argv, cmd_property_set_usage, &types,
>> @@ -446,9 +442,7 @@ static int cmd_property_list(int argc, char **argv)
>> -	if (check_argc_min(argc, 2) || check_argc_max(argc, 4))
>> +	if (check_argc_min(argc, 2))
>
> ...
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/cmds-property.c b/cmds-property.c
index 5b4da26..4c2beb7 100644
--- a/cmds-property.c
+++ b/cmds-property.c
@@ -379,9 +379,7 @@  static int cmd_property_get(int argc, char **argv)
 	char *name = NULL;
 	int types = 0;

-	clean_args_no_options(argc, argv, cmd_property_get_usage);
-
-	if (check_argc_min(argc, 2) || check_argc_max(argc, 5))
+	if (check_argc_min(argc, 2))
 		usage(cmd_property_get_usage);

 	parse_args(argc, argv, cmd_property_get_usage, &types, &object, &name,
@@ -415,9 +413,7 @@  static int cmd_property_set(int argc, char **argv)
 	char *value = NULL;
 	int types = 0;

-	clean_args_no_options(argc, argv, cmd_property_set_usage);
-
-	if (check_argc_min(argc, 4) || check_argc_max(argc, 6))
+	if (check_argc_min(argc, 4))
 		usage(cmd_property_set_usage);

 	parse_args(argc, argv, cmd_property_set_usage, &types,
@@ -446,9 +442,7 @@  static int cmd_property_list(int argc, char **argv)
 	char *object = NULL;
 	int types = 0;

-	clean_args_no_options(argc, argv, cmd_property_list_usage);
-
-	if (check_argc_min(argc, 2) || check_argc_max(argc, 4))
+	if (check_argc_min(argc, 2))
 		usage(cmd_property_list_usage);

 	parse_args(argc, argv, cmd_property_list_usage,