From a00bfc200ccfd27fe2f2bc1d0cd92b81a7bba06f Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Thu, 19 Oct 2017 13:41:34 +0800 Subject: [PATCH] btrfs-progs: mkfs: avoid positive return value from cleanup_temp_chunks Since we're calling btrfs_search_slot() the return value can be positive. However we just pass that return value out, causing undefined return value. This can cause mkfs to return 1, which indicates something wrong. Fix it. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- mkfs/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkfs/main.c b/mkfs/main.c index 1b4cabc1..94f54d81 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -1350,6 +1350,9 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info, ret = btrfs_search_slot(trans, root, &key, &path, 0, 0); if (ret < 0) goto out; + /* Don't pollute ret for >0 case */ + if (ret > 0) + ret = 0; btrfs_item_key_to_cpu(path.nodes[0], &found_key, path.slots[0]); -- 2.11.4.GIT