summaryrefslogtreecommitdiff
path: root/mkfs/options.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-28 16:11:22 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-28 16:11:22 +0100
commit7f53d2785816e5b65dfdb0daa4039249569e58f9 (patch)
treeb8d44ef940d87ccc110501cbe66c5a5a3cbedbfb /mkfs/options.c
parent9e91c1558c40eaabd38f8f422555d6d8831e527f (diff)
Cleanup: Return combined return value from compressor id by name
Instead of returning the ID through a pointer and an error code as return status, return a single int that could be a compressor ID (positive values) or an error code (negative values). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/options.c')
-rw-r--r--mkfs/options.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/mkfs/options.c b/mkfs/options.c
index 31b7731..4dce84e 100644
--- a/mkfs/options.c
+++ b/mkfs/options.c
@@ -146,7 +146,7 @@ const char *help_details =
void process_command_line(options_t *opt, int argc, char **argv)
{
bool have_compressor;
- int i;
+ int i, ret;
memset(opt, 0, sizeof(*opt));
sqfs_writer_cfg_init(&opt->cfg);
@@ -159,25 +159,23 @@ void process_command_line(options_t *opt, int argc, char **argv)
switch (i) {
case 'c':
have_compressor = true;
+ ret = sqfs_compressor_id_from_name(optarg);
- if (sqfs_compressor_id_from_name(optarg,
- &opt->cfg.comp_id)) {
+ if (ret < 0) {
have_compressor = false;
- }
-
- if (!sqfs_compressor_exists(opt->cfg.comp_id))
- have_compressor = false;
-
#ifdef WITH_LZO
- if (opt->cfg.comp_id == SQFS_COMP_LZO)
- have_compressor = true;
+ if (opt->cfg.comp_id == SQFS_COMP_LZO)
+ have_compressor = true;
#endif
+ }
if (!have_compressor) {
fprintf(stderr, "Unsupported compressor '%s'\n",
optarg);
exit(EXIT_FAILURE);
}
+
+ opt->cfg.comp_id = ret;
break;
case 'b':
opt->cfg.block_size = strtol(optarg, NULL, 0);