Commit d18533cc authored by Pablo de Oliveira's avatar Pablo de Oliveira Committed by Ben Pfaff
Browse files

Fix userprog tests for clang

Recent clang version, detect attemps to dereference or call NULL, and
eliminate the code.

../../tests/userprog/bad-read.c:11:9: warning: indirection of
non-volatile null pointer will be deleted, not trap [-Wnull-dereference]
        *(int *) NULL);
        ^~~~~~~~~~~~~

This patchs adds the volatile modifier as necessary.
It allows to use clang to compile the tests.
parent f5fa837e
......@@ -4,10 +4,13 @@
#include "tests/lib.h"
#include "tests/main.h"
typedef int (* volatile functionptr)(void);
void
test_main (void)
{
functionptr fp = NULL;
msg ("Congratulations - you have successfully called NULL: %d",
((int (*)(void))NULL)());
fp());
fail ("should have exited with -1");
}
......@@ -8,6 +8,6 @@ void
test_main (void)
{
msg ("Congratulations - you have successfully dereferenced NULL: %d",
*(int *)NULL);
*(volatile int *) NULL);
fail ("should have exited with -1");
}
......@@ -7,6 +7,6 @@
void
test_main (void)
{
*(int *)NULL = 42;
*(volatile int *)NULL = 42;
fail ("should have exited with -1");
}
......@@ -67,15 +67,15 @@ consume_some_resources_and_die (int seed)
{
consume_some_resources ();
random_init (seed);
int *PHYS_BASE = (int *)0xC0000000;
volatile int *PHYS_BASE = (volatile int *)0xC0000000;
switch (random_ulong () % 5)
{
case 0:
*(int *) NULL = 42;
*(volatile int *) NULL = 42;
case 1:
return *(int *) NULL;
return *(volatile int *) NULL;
case 2:
return *PHYS_BASE;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment