[PATCH] mm/damon: fix sparse warning for zero initializer

Leo Stone posted 1 patch 2 months, 1 week ago
There is a newer version of this series
mm/damon/tests/vaddr-kunit.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mm/damon: fix sparse warning for zero initializer
Posted by Leo Stone 2 months, 1 week ago
sparse warns about zero initializing an array with {0,}, change it to
the equivalent {0}.

Fixes the sparse warning:
mm/damon/tests/vaddr-kunit.h:69:47: warning: missing braces around initializer

Signed-off-by: Leo Stone <leocstone@gmail.com>
---
 mm/damon/tests/vaddr-kunit.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
index a339d117150f..3dad8dfd9005 100644
--- a/mm/damon/tests/vaddr-kunit.h
+++ b/mm/damon/tests/vaddr-kunit.h
@@ -66,7 +66,7 @@ static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
 static void damon_test_three_regions_in_vmas(struct kunit *test)
 {
 	static struct mm_struct mm;
-	struct damon_addr_range regions[3] = {0,};
+	struct damon_addr_range regions[3] = {0};
 	/* 10-20-25, 200-210-220, 300-305, 307-330 */
 	struct vm_area_struct vmas[] = {
 		(struct vm_area_struct) {.vm_start = 10, .vm_end = 20},
-- 
2.43.0
Re: [PATCH] mm/damon: fix sparse warning for zero initializer
Posted by SeongJae Park 2 months, 1 week ago
Hi Leo,


Thank you for this patch!

On Sat, 21 Sep 2024 12:54:45 -0700 Leo Stone <leocstone@gmail.com> wrote:

> sparse warns about zero initializing an array with {0,}, change it to
> the equivalent {0}.
> 
> Fixes the sparse warning:
> mm/damon/tests/vaddr-kunit.h:69:47: warning: missing braces around initializer
> 
> Signed-off-by: Leo Stone <leocstone@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>

I also think below tag would be good to add?

17ccae8bb5c9 ("mm/damon: add kunit tests")

Thanks,
SJ

> ---
>  mm/damon/tests/vaddr-kunit.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
> index a339d117150f..3dad8dfd9005 100644
> --- a/mm/damon/tests/vaddr-kunit.h
> +++ b/mm/damon/tests/vaddr-kunit.h
> @@ -66,7 +66,7 @@ static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
>  static void damon_test_three_regions_in_vmas(struct kunit *test)
>  {
>  	static struct mm_struct mm;
> -	struct damon_addr_range regions[3] = {0,};
> +	struct damon_addr_range regions[3] = {0};
>  	/* 10-20-25, 200-210-220, 300-305, 307-330 */
>  	struct vm_area_struct vmas[] = {
>  		(struct vm_area_struct) {.vm_start = 10, .vm_end = 20},
> -- 
> 2.43.0
[PATCH v2] mm/damon: fix sparse warning for zero initializer
Posted by Leo Stone 2 months, 1 week ago
sparse warns about zero initializing an array with {0,}, change it to
the equivalent {0}.

Fixes the sparse warning:
mm/damon/tests/vaddr-kunit.h:69:47: warning: missing braces around initializer

Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests")
Signed-off-by: Leo Stone <leocstone@gmail.com>
---
v2: Added fixes tag. Thank you! 
---
 mm/damon/tests/vaddr-kunit.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
index a339d117150f..3dad8dfd9005 100644
--- a/mm/damon/tests/vaddr-kunit.h
+++ b/mm/damon/tests/vaddr-kunit.h
@@ -66,7 +66,7 @@ static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
 static void damon_test_three_regions_in_vmas(struct kunit *test)
 {
        static struct mm_struct mm;
-       struct damon_addr_range regions[3] = {0,};
+       struct damon_addr_range regions[3] = {0};
        /* 10-20-25, 200-210-220, 300-305, 307-330 */
        struct vm_area_struct vmas[] = {
                (struct vm_area_struct) {.vm_start = 10, .vm_end = 20},
--
2.43.0