Skip to content

Commit 071c300

Browse files
committed
selftests-cachestat-add-tests-for-mmap-refactor-and-enhance-mmap-test-for-cachestat-validation-checkpatch-fixes
ERROR: "foo* bar" should be "foo *bar" torvalds#41: FILE: tools/testing/selftests/cachestat/test_cachestat.c:209: +const char* file_type_str(enum file_type type) { ERROR: open brace '{' following function definitions go on the next line torvalds#41: FILE: tools/testing/selftests/cachestat/test_cachestat.c:209: +const char* file_type_str(enum file_type type) { ERROR: switch and case should be at the same indent torvalds#42: FILE: tools/testing/selftests/cachestat/test_cachestat.c:210: + switch (type) { + case FILE_SHMEM: [...] + case FILE_MMAP: [...] + default: ERROR: space required after that ',' (ctx:VxV) torvalds#72: FILE: tools/testing/selftests/cachestat/test_cachestat.c:239: + ksft_print_msg("Unable to create %s file.\n",file_type_str(type)); ^ ERROR: space required after that ',' (ctx:VxV) torvalds#79: FILE: tools/testing/selftests/cachestat/test_cachestat.c:245: + ksft_print_msg("Unable to truncate %s file.\n",file_type_str(type)); ^ ERROR: switch and case should be at the same indent torvalds#88: FILE: tools/testing/selftests/cachestat/test_cachestat.c:249: + switch (type){ + case FILE_SHMEM: [...] + case FILE_MMAP: [...] + default: ERROR: space required before the open brace '{' torvalds#88: FILE: tools/testing/selftests/cachestat/test_cachestat.c:249: + switch (type){ WARNING: Missing a blank line after declarations torvalds#98: FILE: tools/testing/selftests/cachestat/test_cachestat.c:259: + char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (map == MAP_FAILED) { WARNING: braces {} are not necessary for single statement blocks torvalds#103: FILE: tools/testing/selftests/cachestat/test_cachestat.c:264: + for (int i = 0; i < filesize; i++) { + map[i] = 'A'; + } WARNING: break is not useful after a goto torvalds#111: FILE: tools/testing/selftests/cachestat/test_cachestat.c:272: + goto close_fd; + break; total: 7 errors, 3 warnings, 108 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. ./patches/selftests-cachestat-add-tests-for-mmap-refactor-and-enhance-mmap-test-for-cachestat-validation.patch has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Please run checkpatch prior to sending patches Cc: Johannes Weiner <[email protected]> Cc: Joshua Hahn <[email protected]> Cc: Nhat Pham <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Suresh K C <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4f37070 commit 071c300

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

tools/testing/selftests/cachestat/test_cachestat.c

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,15 @@ static int test_cachestat(const char *filename, bool write_random, bool create,
206206
out:
207207
return ret;
208208
}
209-
const char* file_type_str(enum file_type type) {
209+
const char *file_type_str(enum file_type type)
210+
{
210211
switch (type) {
211-
case FILE_SHMEM:
212-
return "shmem";
213-
case FILE_MMAP:
214-
return "mmap";
215-
default:
216-
return "unknown";
212+
case FILE_SHMEM:
213+
return "shmem";
214+
case FILE_MMAP:
215+
return "mmap";
216+
default:
217+
return "unknown";
217218
}
218219
}
219220

@@ -236,7 +237,8 @@ bool run_cachestat_test(enum file_type type)
236237
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0666);
237238

238239
if (fd < 0) {
239-
ksft_print_msg("Unable to create %s file.\n",file_type_str(type));
240+
ksft_print_msg("Unable to create %s file.\n",
241+
file_type_str(type));
240242
ret = false;
241243
goto out;
242244
}
@@ -246,30 +248,30 @@ bool run_cachestat_test(enum file_type type)
246248
ret = false;
247249
goto close_fd;
248250
}
249-
switch (type){
250-
case FILE_SHMEM:
251-
if (!write_exactly(fd, filesize)) {
252-
ksft_print_msg("Unable to write to file.\n");
253-
ret = false;
254-
goto close_fd;
255-
}
256-
break;
257-
case FILE_MMAP:
258-
char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
259-
if (map == MAP_FAILED) {
260-
ksft_print_msg("mmap failed.\n");
261-
ret = false;
262-
goto close_fd;
263-
}
264-
for (int i = 0; i < filesize; i++) {
265-
map[i] = 'A';
266-
}
267-
break;
268-
default:
269-
ksft_print_msg("Unsupported file type.\n");
251+
switch (type) {
252+
case FILE_SHMEM:
253+
if (!write_exactly(fd, filesize)) {
254+
ksft_print_msg("Unable to write to file.\n");
270255
ret = false;
271256
goto close_fd;
272-
break;
257+
}
258+
break;
259+
case FILE_MMAP:
260+
char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
261+
MAP_SHARED, fd, 0);
262+
263+
if (map == MAP_FAILED) {
264+
ksft_print_msg("mmap failed.\n");
265+
ret = false;
266+
goto close_fd;
267+
}
268+
for (int i = 0; i < filesize; i++)
269+
map[i] = 'A';
270+
break;
271+
default:
272+
ksft_print_msg("Unsupported file type.\n");
273+
ret = false;
274+
goto close_fd;
273275
}
274276
syscall_ret = syscall(__NR_cachestat, fd, &cs_range, &cs, 0);
275277

0 commit comments

Comments
 (0)