btrfs-progs/cmds
Qu Wenruo f61b90aff9 btrfs-progs: make usage call properly return an exit value
[BUG]
Currently cli/009 test case failed with different exit number:

  ====== RUN CHECK /home/adam/btrfs-progs/btrfstune --help
  usage: btrfstune [options] device
  [...]
  failed: /home/adam/btrfs-progs/btrfstune --help
  test failed for case 009-btrfstune

[CAUSE]
In tune/main.c, we have the following call on usage():

  static void print_usage(int ret)
  {
	usage(&tune_cmd);
	exit(ret);
  }

However usage() itself would always call exit(1):

  void usage(const struct cmd_struct *cmd)
  {
	usage_command_usagestr(cmd->usagestr, NULL, 0, true, true);
	exit(1);
  }

This makes prevents any caller of usage() to modify its exit number.

[FIX]
Add a new argument @error for print_usage(), so we can properly return 0
for -h/--help usage.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
..
balance.c btrfs-progs: cmds: use bool for status variables 2022-10-11 09:08:12 +02:00
commands.h btrfs-progs: add new group reflink and command 2022-12-07 01:43:30 +01:00
device.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
filesystem-du.c btrfs-progs: cmds: use bool for status variables 2022-10-11 09:08:12 +02:00
filesystem-usage.c btrfs-progs: read fsid from the sysfs in device_is_seed 2023-02-28 20:11:23 +01:00
filesystem-usage.h btrfs-progs: fi usage: unify naming of device and chunk info variables 2022-10-11 09:08:08 +02:00
filesystem.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
inspect-dump-super.c btrfs-progs: cmds: use bool for status variables 2022-10-11 09:08:12 +02:00
inspect-dump-tree.c btrfs-progs: replace strerror(errno) with %m in printf formats 2022-10-26 09:46:22 +02:00
inspect-tree-stats.c btrfs-progs: cmds: use bool for status variables 2022-10-11 09:08:12 +02:00
inspect.c btrfs-progs: build: use plain fcntl.h instead of sys/fcntl.h 2023-02-28 19:49:30 +01:00
property.c btrfs-progs: property: use pr_verbose for messages 2022-10-11 09:08:11 +02:00
props.h btrfs-progs: prop set: add force parameter 2021-10-07 18:40:24 +02:00
qgroup.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
qgroup.h Revert "btrfs-progs: rename qgroup items to match the kernel naming scheme" 2023-01-03 13:10:54 +01:00
quota.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
receive-dump.c btrfs-progs: receive: add support for fs-verity 2022-10-11 09:08:08 +02:00
receive-dump.h btrfs-progs: cmds: update include lists 2022-10-11 09:07:59 +02:00
receive.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
reflink.c btrfs-progs: build: use plain fcntl.h instead of sys/fcntl.h 2023-02-28 19:49:30 +01:00
replace.c btrfs-progs: ioctl: move dev-replace NO_RESULT definition into replace.c 2022-11-28 18:57:43 +01:00
rescue-chunk-recover.c btrfs-progs: don't use btrfs_header_csum helper 2022-11-30 19:14:29 +01:00
rescue-super-recover.c btrfs-progs: cmds: update include lists 2022-10-11 09:07:59 +02:00
rescue.c btrfs-progs: cmds: use bool for status variables 2022-10-11 09:08:12 +02:00
rescue.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
restore.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
scrub.c btrfs-progs: fix set but not used variables 2023-02-18 17:44:03 +01:00
send.c btrfs-progs: replace strerror(errno) with %m in printf formats 2022-10-26 09:46:22 +02:00
subvolume-list.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00
subvolume.c btrfs-progs: make usage call properly return an exit value 2023-02-28 20:11:23 +01:00