btrfs-progs: mkfs: open code profile parsing helper

There's a helper to parse profile name and exits on error. As this is a
trivial helper we can open code it and adapt the error message to be
more specific what failed.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-09-14 16:53:54 +02:00
parent e331037d40
commit 74be9f5115
1 changed files with 10 additions and 16 deletions

View File

@ -421,20 +421,6 @@ static void print_usage(int ret)
exit(ret);
}
static u64 parse_profile(const char *s)
{
int ret;
u64 flags = 0;
ret = parse_bg_profile(s, &flags);
if (ret) {
error("unknown profile %s", s);
exit(1);
}
return flags;
}
static char *parse_label(const char *input)
{
int len = strlen(input);
@ -1053,7 +1039,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
force_overwrite = true;
break;
case 'd':
data_profile = parse_profile(optarg);
ret = parse_bg_profile(optarg, &data_profile);
if (ret) {
error("unknown data profile %s", optarg);
exit(1);
}
data_profile_opt = true;
break;
case 'l':
@ -1067,7 +1057,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
label = parse_label(optarg);
break;
case 'm':
metadata_profile = parse_profile(optarg);
ret = parse_bg_profile(optarg, &metadata_profile);
if (ret) {
error("unknown metadata profile %s", optarg);
exit(1);
}
metadata_profile_opt = true;
break;
case 'M':