Skip to content

Commit 44b4c1b

Browse files
committed
fix(test): check for mmap errors before using pointer
mmap should never fail, but having the check for failure after the memset is just wrong. Signed-off-by: Patrick Roy <[email protected]>
1 parent 34337a6 commit 44b4c1b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

resources/overlay/usr/local/bin/fast_page_fault_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ int main(int argc, char *const argv[]) {
3030

3131
ptr = mmap(NULL, MEM_SIZE_MIB, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
3232

33-
memset(ptr, 1, MEM_SIZE_MIB);
34-
3533
if (MAP_FAILED == ptr) {
3634
perror("mmap");
3735
return -1;
3836
}
3937

38+
memset(ptr, 1, MEM_SIZE_MIB);
39+
4040
sigwait(&set, &signal);
4141

4242
memset(ptr, 2, MEM_SIZE_MIB);

0 commit comments

Comments
 (0)