[1/2] btrfs-progs: Remove unnecessary variable devstart from cmd_device_scan()
diff mbox

Message ID 56E0AC1B.3020405@jp.fujitsu.com
State New
Headers show

Commit Message

Satoru Takeuchi March 9, 2016, 11:04 p.m. UTC
It's unnecessary since it's always 1.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
This patch can be applied to devel (commit b2bdd0da8969).
---
 cmds-device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

David Sterba March 10, 2016, 1:27 p.m. UTC | #1
On Thu, Mar 10, 2016 at 08:04:59AM +0900, Satoru Takeuchi wrote:
> It's unnecessary since it's always 1.
> 
> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
> ---
> This patch can be applied to devel (commit b2bdd0da8969).
> ---
>  cmds-device.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/cmds-device.c b/cmds-device.c
> index cb470af..78d6535 100644
> --- a/cmds-device.c
> +++ b/cmds-device.c
> @@ -246,7 +246,6 @@ static const char * const cmd_device_scan_usage[] = {
>  static int cmd_device_scan(int argc, char **argv)
>  {
>  	int i;
> -	int devstart = 1;
>  	int all = 0;
>  	int ret = 0;
> 
> @@ -282,7 +281,7 @@ static int cmd_device_scan(int argc, char **argv)
>  		goto out;
>  	}
> 
> -	for( i = devstart ; i < argc ; i++ ){
> +	for (i = 1; i < argc; i++) {

Actually it needs to be set to optind before the for cycle, otherwise:

  # btrfs device scan -- /dev/sda
  ERROR: not a block device: --
--
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 10, 2016, 11:18 p.m. UTC | #2
On 2016/03/10 22:27, David Sterba wrote:
> On Thu, Mar 10, 2016 at 08:04:59AM +0900, Satoru Takeuchi wrote:
>> It's unnecessary since it's always 1.
>>
>> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>> ---
>> This patch can be applied to devel (commit b2bdd0da8969).
>> ---
>>   cmds-device.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/cmds-device.c b/cmds-device.c
>> index cb470af..78d6535 100644
>> --- a/cmds-device.c
>> +++ b/cmds-device.c
>> @@ -246,7 +246,6 @@ static const char * const cmd_device_scan_usage[] = {
>>   static int cmd_device_scan(int argc, char **argv)
>>   {
>>   	int i;
>> -	int devstart = 1;
>>   	int all = 0;
>>   	int ret = 0;
>>
>> @@ -282,7 +281,7 @@ static int cmd_device_scan(int argc, char **argv)
>>   		goto out;
>>   	}
>>
>> -	for( i = devstart ; i < argc ; i++ ){
>> +	for (i = 1; i < argc; i++) {
>
> Actually it needs to be set to optind before the for cycle, otherwise:
>
>    # btrfs device scan -- /dev/sda
>    ERROR: not a block device: --

Thank you for your comment. I'll fix it.

Satoru
--
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-device.c b/cmds-device.c
index cb470af..78d6535 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -246,7 +246,6 @@  static const char * const cmd_device_scan_usage[] = {
 static int cmd_device_scan(int argc, char **argv)
 {
 	int i;
-	int devstart = 1;
 	int all = 0;
 	int ret = 0;

@@ -282,7 +281,7 @@  static int cmd_device_scan(int argc, char **argv)
 		goto out;
 	}

-	for( i = devstart ; i < argc ; i++ ){
+	for (i = 1; i < argc; i++) {
 		char *path;

 		if (is_block_device(argv[i]) != 1) {