btrfs-progs: fix defrag -c option parsing

The refactoring f3a132fa1b ("btrfs-progs: factor out compression type
name parsing to common utils") caused a bug with parsing option -c with
defrag:

  # btrfs fi defrag -v -czstd file
  ERROR: unknown compression type: zstd

  # btrfs fi defrag -v -clzo file
  ERROR: unknown compression type: lzo

  # btrfs fi defrag -v -czlib file
  ERROR: unknown compression type: zlib

Fix it by properly checking the value representing unknown compression
algorithm.

Issue: #403
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-09-18 17:44:57 +02:00
parent 38f19d161c
commit 61e00694e7

View File

@ -835,7 +835,7 @@ static int parse_compress_type_arg(char *s)
int ret;
ret = parse_compress_type(s);
if (ret) {
if (ret < 0) {
error("unknown compression type: %s", s);
exit(1);
}