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

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>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Marek Rusinowski 2016-05-04 15:36:35 +02:00 committed by David Sterba
parent 5c5a622772
commit a6bbbe6087
1 changed files with 2 additions and 3 deletions

View File

@ -1195,10 +1195,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;
}