Skip to content

Commit 920aa3a

Browse files
sidharth-458shuahkh
authored andcommitted
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, | Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sidharth Seela <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Reviewed-by: wang lian <[email protected]> Reviewed-by: Dev Jain <[email protected]> Acked-by: Shuah Khan <[email protected]> Acked-by: Nhat Pham <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent b90cafb commit 920aa3a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/cachestat/test_cachestat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bool run_cachestat_test(enum file_type type)
226226
int syscall_ret;
227227
size_t compute_len = PS * 512;
228228
struct cachestat_range cs_range = { PS, compute_len };
229-
char *filename = "tmpshmcstat";
229+
char *filename = "tmpshmcstat", *map;
230230
struct cachestat cs;
231231
bool ret = true;
232232
int fd;
@@ -257,7 +257,7 @@ bool run_cachestat_test(enum file_type type)
257257
}
258258
break;
259259
case FILE_MMAP:
260-
char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
260+
map = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
261261
MAP_SHARED, fd, 0);
262262

263263
if (map == MAP_FAILED) {

0 commit comments

Comments
 (0)