diff mbox series

ocfs2: remove useless code in ocfs2_try_to_merge_extent

Message ID 20240112042639.3948236-1-suhui@nfschina.com (mailing list archive)
State New, archived
Headers show
Series ocfs2: remove useless code in ocfs2_try_to_merge_extent | expand

Commit Message

Su Hui Jan. 12, 2024, 4:26 a.m. UTC
Clang static checker warning: Value stored to 'rec' is never read.
Remove this useless code to silent this warning.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 fs/ocfs2/alloc.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Andrew Morton Jan. 16, 2024, 8:09 p.m. UTC | #1
On Fri, 12 Jan 2024 12:26:40 +0800 Su Hui <suhui@nfschina.com> 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.
Su Hui Jan. 17, 2024, 1:23 a.m. UTC | #2
On 2024/1/17 04:09, Andrew Morton wrote:
> On Fri, 12 Jan 2024 12:26:40 +0800 Su Hui <suhui@nfschina.com> 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.
>
Oh, really sorry for the noise.
This patch is wrong.

Su Hui
diff mbox series

Patch

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index ea9127ba3208..71729e4326d3 100644
--- 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.