Re: [PATCH] btrfs: turn unpin_extent_cache() into a void function

From: Johannes Thumshirn
Date: Thu Jul 20 2023 - 03:13:39 EST


On 18.07.23 19:39, Luís Henriques wrote:
> The value of the 'ret' variable is never changed in function
> unpin_extent_cache(). And since the only caller of this function doesn't
> check the return value, it can simply be turned into a void function.
>
> Signed-off-by: Luís Henriques <lhenriques@xxxxxxx>

Hmm but inside unpin_extent_cache() there is this:


/* [...] */
em = lookup_extent_mapping(tree, start, len);

WARN_ON(!em || em->start != start);

if (!em)
goto out;
/* [...] */

out:
write_unlock(&tree->lock);
return ret;

}

Wouldn't it be better to either actually handle the error, OR
change the WARN_ON() into an ASSERT()?

Given the fact, that if the lookup fails, we've passed wrong
parameters somehow, an ASSERT() would be a good way IMHO.

Thoughts?