tools/testing/selftests/vm/split_huge_page_test.c: fix application of sizeof to pointer
authorDavid Yang <davidcomponentone@gmail.com>
Thu, 28 Oct 2021 21:36:36 +0000 (14:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Oct 2021 00:18:55 +0000 (17:18 -0700)
The coccinelle check report:

  ./tools/testing/selftests/vm/split_huge_page_test.c:344:36-42:
  ERROR: application of sizeof to pointer

Use "strlen" to fix it.

Link: https://lkml.kernel.org/r/20211012030116.184027-1-davidcomponentone@gmail.com
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Reported-by: Zeal Robot <zealci@zte.com.cn>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
tools/testing/selftests/vm/split_huge_page_test.c

index 1af16d2c2a0acb5ea27b7e5e8f8dc864c27a416f..52497b7b9f1db3e7203ea476b03b19b5e643b763 100644 (file)
@@ -341,7 +341,7 @@ void split_file_backed_thp(void)
        }
 
        /* write something to the file, so a file-backed THP can be allocated */
-       num_written = write(fd, tmpfs_loc, sizeof(tmpfs_loc));
+       num_written = write(fd, tmpfs_loc, strlen(tmpfs_loc) + 1);
        close(fd);
 
        if (num_written < 1) {