selftests: cachestat: Fix warning on declaration under label
Subsystems (3)
PATCH 1/1 selftests: cachestat: Fix warning on declaration under label
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
|
---
tools/testing/selftests/cachestat/test_cachestat.c +2 -2
@@ -226,7 +226,7 @@ bool run_cachestat_test(enum file_type type)int syscall_ret;size_t compute_len =PS *512 ;struct cachestat_range cs_range = {PS , compute_len }; -char *filename ="tmpshmcstat" ; +char *filename ="tmpshmcstat" , *map;struct cachestat cs;bool ret = true;int fd;
@@ -257,7 +257,7 @@ bool run_cachestat_test(enum file_type type) }break ;case FILE_MMAP : -char *map =mmap (NULL , filesize,PROT_READ |PROT_WRITE , + map =mmap (NULL , filesize,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 );if (map ==MAP_FAILED ) {
Signature · 1 line
2.47.3
Quoted 9 lines · On Mon, 29 Sep 2025 17:24:06 +0530 Sidharth Seela <[email protected]>…
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize,PROT_READ|PROT_WRITE,|Signed-off-by Sidharth Seela <[email protected]>
Thanks,
SJ
[...]
lianux
Reviewed-byFrom: wang lian <[email protected]>
Quoted 9 lines
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize,PROT_READ|PROT_WRITE,|Signed-off-by Sidharth Seela <[email protected]>
Best regards,
wang lian
Quoted 10 lines · SeongJae Park
Quoted 8 lines · On Mon, 29 Sep 2025 17:24:06 +0530 Sidharth Seela <[email protected]>…
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize,PROT_READ|PROT_WRITE,|
Quoted 5 lines
Quoted 1 line
Signed-off-by Sidharth Seela <[email protected]>Reviewed-by SeongJae Park <[email protected]>
Johannes and Nhat,
Assuming this will go through cachestat tree
Let me know if you would like me to take this through my tree.
thanks,
-- Shuah
Quoted 18 lines · Shuah Khan
Quoted 10 lines · SeongJae Park
Quoted 8 lines · On Mon, 29 Sep 2025 17:24:06 +0530 Sidharth Seela <[email protected]>…
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize,PROT_READ|PROT_WRITE,|Quoted 5 lines
Quoted 1 line
Signed-off-by Sidharth Seela <[email protected]>Reviewed-by SeongJae Park <[email protected]>
Quoted 6 lines
Johannes and Nhat,
Assuming this will go through cachestat tree
Acked-by Shuah Khan <[email protected]>
Hi Shuah.
LGTM:
Quoted 11 lines · Sidharth Seela
Fix warning caused from declaration under a case label. The proper way
is to declare variable at the beginning of the function. The warning
came from running clang using LLVM=1; and is as follows:
--
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
260 | char *map = mmap(NULL, filesize,PROT_READ|PROT_WRITE,|Signed-off-by Sidharth Seela <[email protected]>---
Shuah Khan
maintainerQuoted 6 lines · Dev Jain
Quoted 4 lines · Sidharth Seela
Fix warning caused from declaration under a case label. The proper way is to declare variable at the beginning of the function. The warning came from running clang using LLVM=1; and is as follows:
Sidharth,
Make sure to not use "---" in your commit logs. Everything after this line gets thrown away. I had to go fix it manually.
Quoted 10 lines
Quoted 7 lines
-test_cachestat.c:260:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions] 260 | char *map = mmap(NULL, filesize,
PROT_READ|PROT_WRITE,
|Signed-off-by Sidharth Seela <[email protected]>---
Reviewed-by Dev Jain <[email protected]>
Applied to linux-kselftest fixes branch for next rc.
thanks,
-- Shuah
Quoted 2 lines
Make sure to not use "---" in your commit logs. Everything after this line gets thrown away. I had to go fix it manually.
Sorry, I will make sure that doesn't happen again.
Signature · 2 lines
Thanks, Sidharth Seela