Skip to contentSkip to conversation

testing/vm/: fix application of sizeof to pointer

PATCH In review CGEL 2 participants 2 messages Aug 20, 2021 – Aug 24, 2021

Subsystems (2)
lore
Share & tools
lore

CGEL

author
#0 lore raw

PATCH 1/1 testing/vm/: fix application of sizeof to pointer

From: jing yangyang <[email protected]>

sizeof when applied to a pointer typed expression gives the size of the pointer.

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

This issue was detected with the help of Coccinelle.

---
 tools/testing/selftests/vm/split_huge_page_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/split_huge_page_test.c +1 -1
index 1af16d2..54bf57f 100644
@@ -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, sizeof(*tmpfs_loc));
 	close(fd);
 
 	if (num_written < 1) {
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 22 lines · CGEL

From: jing yangyang <[email protected]>

sizeof when applied to a pointer typed expression gives the size of the pointer.

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

This issue was detected with the help of Coccinelle.

---
  tools/testing/selftests/vm/split_huge_page_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/split_huge_page_test.c +0 -0
index 1af16d2..54bf57f 100644

tools/testing/selftests/vm/split_huge_page_test.c void split_file_backed_thp(void) · line 347

Quoted 8 lines
tools/testing/selftests/vm/split_huge_page_test.c +1 -1
@@ -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, sizeof(*tmpfs_loc));
  	close(fd);
 
  	if (num_written < 1) {

We can't accept this patch. The from and Signed-off-by don't match.

thanks,
-- Shuah