Skip to contentSkip to conversation

btrfs-progs: Remove unnecessary variable devstart from cmd_device_scan()

PATCH Applied Satoru Takeuchi 2 participants 5 messages Mar 9, 2016 – Mar 10, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 btrfs-progs: Remove unnecessary variable devstart from cmd_device_scan()

It's unnecessary since it's always 1.

---
This patch can be applied to devel (commit b2bdd0da8969).

---
 cmds-device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
cmds-device.c +1 -2
index cb470af..78d6535 100644
@@ -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) {
Signature · 1 line
2.7.0
#1 lore raw

PATCH 2/2 btrfs-progs: Describe device scan -d is a deprecated option in manpage

It's already marked as deprecated in cmd_device_scan_usage().

commit 5444864e5605 ("btrfs-progs: remove BTRFS_SCAN_PROC scan method")

---
 Documentation/btrfs-device.asciidoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/btrfs-device.asciidoc +2 -2
index bd878f4..bf16a94 100644
@@ -89,8 +89,8 @@ Scan devices for a btrfs filesystem.
 If one or more devices are passed, these are scanned for a btrfs filesystem.
 If no devices are passed, btrfs uses block devices containing btrfs
 filesystem as listed by blkid.
-Finally, if '--all-devices' or '-d' is passed, all the devices under /dev are
-scanned.
+Finally, '--all-devices' or '-d' is the deprecated option. If it is passed,
+its behavior is the same as if no devices are passed.
 
 *stats* [-z] <path>|<device>::
 Read and print the device IO stats for all mounted devices of the filesystem
Signature · 1 line
2.7.0
Applied
#2 lore raw

Re: [PATCH 2/2] btrfs-progs: Describe device scan -d is a deprecated option in manpage

Quoted 5 lines · Satoru Takeuchi

It's already marked as deprecated in cmd_device_scan_usage().

commit 5444864e5605 ("btrfs-progs: remove BTRFS_SCAN_PROC scan method")

Applied, thanks.

#3 lore raw
In reply to Satoru Takeuchi
Quoted 22 lines · Satoru Takeuchi

It's unnecessary since it's always 1.

---
This patch can be applied to devel (commit b2bdd0da8969).

---
 cmds-device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
cmds-device.c +0 -1
index cb470af..78d6535 100644
@@ -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;
 

cmds-device.c static int cmd_device_scan(int argc, char **argv) · line 284

Quoted 5 lines
cmds-device.c +1 -1
@@ -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: --
#4 lore raw
Quoted 26 lines · David Sterba
Quoted 25 lines · Satoru Takeuchi

It's unnecessary since it's always 1.

---
This patch can be applied to devel (commit b2bdd0da8969).

---
  cmds-device.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
cmds-device.c +0 -1
index cb470af..78d6535 100644
@@ -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;
  	}
 
Quoted 7 lines

cmds-device.c static int cmd_device_scan(int argc, char **argv) · line 284

Quoted 2 lines
cmds-device.c +1 -1
-	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