[PATCH v1] lib:Remove repeated initialization

Wang Ming posted 1 patch 2 years, 7 months ago
lib/test_maple_tree.c | 1 -
1 file changed, 1 deletion(-)
[PATCH v1] lib:Remove repeated initialization
Posted by Wang Ming 2 years, 7 months ago
The original code initializes 'entry' 
twice in line 3229 and 3232, which 
causes duplicate initialization issue.
To fix this, we remove the initialization
of 'entry' in line 3229.

Signed-off-by: Wang Ming <machel@vivo.com>
---
 lib/test_maple_tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
index 9f60e0c4cc8c..2ec14c310dad 100644
--- a/lib/test_maple_tree.c
+++ b/lib/test_maple_tree.c
@@ -3226,7 +3226,6 @@ static noinline void __init check_state_handling(struct maple_tree *mt)
 
 	/* next: none -> active, skip value at location */
 	mas_set(&mas, 0);
-	entry = mas_next(&mas, ULONG_MAX);
 	mas.node = MAS_NONE;
 	mas.offset = 0;
 	entry = mas_next(&mas, ULONG_MAX);
-- 
2.25.1
Re: [PATCH v1] lib:Remove repeated initialization
Posted by Matthew Wilcox 2 years, 7 months ago
On Thu, Jul 06, 2023 at 10:03:01PM +0800, Wang Ming wrote:
> The original code initializes 'entry' 
> twice in line 3229 and 3232, which 
> causes duplicate initialization issue.
> To fix this, we remove the initialization
> of 'entry' in line 3229.

mas_next() has a side-effect; it's not a pure initialisation.
Fix your tool.