diff mbox

btrfs-progs: subvolume sync: fix handling of -s option

Message ID 1462368995-24542-1-git-send-email-marekrusinowski@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Marek Rusinowski May 4, 2016, 1:36 p.m. UTC
Setting check interval for subvolume sync resulted
in picking wrong element from argv for it's value:

  $ btrfs subvolume sync -s 10 ./dir
  ERROR: invalid sleep interval ./dir
  $ btrfs subvolume sync ./dir -s 10
  Segmentation fault

Signed-off-by: Marek Rusinowski <marekrusinowski@gmail.com>
---
 cmds-subvolume.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

David Sterba May 4, 2016, 1:57 p.m. UTC | #1
On Wed, May 04, 2016 at 03:36:35PM +0200, Marek Rusinowski wrote:
> Setting check interval for subvolume sync resulted
> in picking wrong element from argv for it's value:
> 
>   $ btrfs subvolume sync -s 10 ./dir
>   ERROR: invalid sleep interval ./dir
>   $ btrfs subvolume sync ./dir -s 10
>   Segmentation fault
> 
> Signed-off-by: Marek Rusinowski <marekrusinowski@gmail.com>

Applied, thanks.
--
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
diff mbox

Patch

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 2319684..c444617 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -1194,10 +1194,9 @@  static int cmd_subvol_sync(int argc, char **argv)
 
 		switch (c) {
 		case 's':
-			sleep_interval = atoi(argv[optind]);
+			sleep_interval = atoi(optarg);
 			if (sleep_interval < 1) {
-				error("invalid sleep interval %s",
-					argv[optind]);
+				error("invalid sleep interval %s", optarg);
 				ret = 1;
 				goto out;
 			}