From c7d546ab6be82a458650e180535e9a5bcd6e99b0 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 4 Mar 2019 17:04:18 +0100 Subject: [PATCH] btrfs-progs: qgoup: propagate errors from btrfs_qgroup_parse_sort_string Get rid of the exit inside and propagate errors to the callers. Signed-off-by: David Sterba --- qgroup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qgroup.c b/qgroup.c index 8e5a5997..4bbb2a59 100644 --- a/qgroup.c +++ b/qgroup.c @@ -468,9 +468,8 @@ int btrfs_qgroup_setup_comparer(struct btrfs_qgroup_comparer_set **comp_set, tmp = set; set = realloc(set, size); if (!set) { - error("memory allocation failed"); free(tmp); - exit(1); + return -ENOMEM; } memset(&set->comps[set->total], 0, @@ -1211,7 +1210,7 @@ int btrfs_qgroup_parse_sort_string(const char *opt_arg, char **ptr_argv; int what_to_sort; char *opt_tmp; - int ret = 0; + int ret = 0, ret2; opt_tmp = strdup(opt_arg); if (!opt_tmp) @@ -1256,7 +1255,12 @@ int btrfs_qgroup_parse_sort_string(const char *opt_arg, ret = 1; goto out; } - btrfs_qgroup_setup_comparer(comps, what_to_sort, order); + ret2 = btrfs_qgroup_setup_comparer(comps, what_to_sort, + order); + if (ret2 < 0) { + ret = ret2; + goto out; + } } p = strtok(NULL, ","); }