kasan: use %zd format for printing size_t
Subsystems (2)
PATCH 1/1 kasan: use %zd format for printing size_t
From: Arnd Bergmann <[email protected]>
The size_t type depends on the architecture, so %lu does not work on most 32-bit ones:
In file included from include/kunit/assert.h:13,
from include/kunit/test.h:12,
from mm/kasan/report.c:12:
mm/kasan/report.c: In function 'describe_object_addr':
include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
mm/kasan/report.c:270:9: note: in expansion of macro 'pr_err'
270 | pr_err("The buggy address is located %d bytes %s of\n"
| ^~~~~~Fixes 0e301731f558 ("kasan: infer allocation size by scanning metadata")
Signed-off-by Arnd Bergmann <[email protected]>
--- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/report.c +1 -1
@@ -268,7 +268,7 @@ static void describe_object_addr(const void *addr, struct kasan_report_info *inf }pr_err ("The buggy address is located %d bytes %s of\n" -" %s%lu-byte region [%px, %px)\n" , +" %s%zu-byte region [%px, %px)\n" , rel_bytes, rel_type, region_state, info->alloc_size, (void *)object_addr, (void *)(object_addr + info->alloc_size)); }
Signature · 1 line
2.39.0
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
size_ttype depends on the architecture, so %lu does not work on most 32-bit ones:In file included from
include/kunit/assert.h:13,from include/kunit/test.h:12, from mm/kasan/report.c:12: mm/kasan/report.c: In function 'describe_object_addr': include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=] mm/kasan/report.c:270:9: note: in expansion of macro 'pr_err' 270 | pr_err("The buggy address is located %d bytes %s of\n" | ^~~~~~
Quoted 2 lines
Fixes 0e301731f558 ("kasan: infer allocation size by scanning metadata")Signed-off-by Arnd Bergmann <[email protected]>
Reviewed-by Randy Dunlap <[email protected]>
Tested-by Randy Dunlap <[email protected]>
Thanks.
Quoted 17 lines
--- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/report.c +1
-1@@ -268,7 +268,7 @@ static void describe_object_addr(const void *addr, struct kasan_report_info *inf }pr_err ("The buggy address is located %d bytes %s of\n" -" %s%lu-byte region [%px, %px)\n" , +" %s%zu-byte region [%px, %px)\n" , rel_bytes, rel_type, region_state, info->alloc_size, (void *)object_addr, (void *)(object_addr + info->alloc_size)); }
Signature · 1 line
~Randy
Quoted 35 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
size_ttype depends on the architecture, so %lu does not work on most 32-bit ones:In file included from
include/kunit/assert.h:13,from include/kunit/test.h:12, from mm/kasan/report.c:12: mm/kasan/report.c: In function 'describe_object_addr': include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=] mm/kasan/report.c:270:9: note: in expansion of macro 'pr_err' 270 | pr_err("The buggy address is located %d bytes %s of\n" | ^~~~~~Fixes 0e301731f558 ("kasan: infer allocation size by scanning metadata")Signed-off-by Arnd Bergmann <[email protected]>--- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/report.c +1
-2@@ -268,7 +268,7 @@ static void describe_object_addr(const void *addr, struct kasan_report_info *inf }pr_err ("The buggy address is located %d bytes %s of\n" -" %s%lu-byte region [%px, %px)\n" , +" %s%zu-byte region [%px, %px)\n" , rel_bytes, rel_type, region_state, info->alloc_size, (void *)object_addr, (void *)(object_addr + info->alloc_size)); } --
Quoted 2 lines
2.39.0
Reviewed-by Andrey Konovalov <[email protected]>
Thanks!