for (i = 1; i < argc; i++)
do_setattr(argv[i], opts);
+ bch2_opt_strs_free(&opts);
return 0;
}
fs_opts,
opts,
devices.item, darray_size(devices));
+ bch2_opt_strs_free(&fs_opt_strs);
if (!quiet)
bch2_sb_print(sb, false, 1 << BCH_SB_FIELD_members, HUMAN_READABLE);
if (format_opts.encrypted && !no_passphrase)
format_opts.passphrase = read_passphrase_twice("Enter passphrase: ");
- return migrate_fs(fs_path,
- fs_opt_strs,
- fs_opts,
- format_opts, force);
+ int ret = migrate_fs(fs_path,
+ fs_opt_strs,
+ fs_opts,
+ format_opts, force);
+ bch2_opt_strs_free(&fs_opt_strs);
+ return ret;
}
static void migrate_superblock_usage(void)
/* option parsing */
+void bch2_opt_strs_free(struct bch_opt_strs *opts)
+{
+ unsigned i;
+
+ for (i = 0; i < bch2_opts_nr; i++) {
+ free(opts->by_id[i]);
+ opts->by_id[i] = NULL;
+ }
+}
+
struct bch_opt_strs bch2_cmdline_opts_get(int *argc, char *argv[],
unsigned opt_types)
{
optid = bch2_opt_lookup(optstr);
if (optid < 0 ||
!(bch2_opt_table[optid].mode & opt_types)) {
- free(optstr);
i++;
- continue;
+ goto next;
}
if (!valstr &&
if (!valstr)
valstr = "1";
- opts.by_id[optid] = valstr;
+ opts.by_id[optid] = strdup(valstr);
*argc -= nr_args;
memmove(&argv[i],
&argv[i + nr_args],
sizeof(char *) * (*argc - i));
argv[*argc] = NULL;
+next:
+ free(optstr);
}
return opts;
};
};
+void bch2_opt_strs_free(struct bch_opt_strs *);
struct bch_opt_strs bch2_cmdline_opts_get(int *, char *[], unsigned);
struct bch_opts bch2_parse_opts(struct bch_opt_strs);
void bch2_opts_usage(unsigned);
BUG_ON(ret == -EINTR);
+ kfree(path.entries);
+
return bch2_trans_exit(&trans) ?: ret;
}