From 74be9f5115743222cffb9bb02f89e6932f593b01 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 14 Sep 2022 16:53:54 +0200 Subject: [PATCH] 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 --- mkfs/main.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/mkfs/main.c b/mkfs/main.c index 8faf2bc4..d96f66d6 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -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':