Re: [PATCH] ocfs2: remove useless code in ocfs2_try_to_merge_extent

From: Andrew Morton
Date: Tue Jan 16 2024 - 17:10:57 EST


On Fri, 12 Jan 2024 12:26:40 +0800 Su Hui <suhui@xxxxxxxxxxxx> wrote:

> Clang static checker warning: Value stored to 'rec' is never read.
> Remove this useless code to silent this warning.
>
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -3743,8 +3743,6 @@ static int ocfs2_try_to_merge_extent(handle_t *handle,
> goto out;
> }
>
> - rec = &el->l_recs[split_index];
> -
> /*
> * Note that we don't pass split_rec here on purpose -
> * we've merged it into the rec already.

Then:

ret = ocfs2_merge_rec_left(path, handle, et, rec,
dealloc, split_index);

and ocfs2_merge_rec_left() almost immediately dereferences `rec'.

So this looks quite wrong to me.