tests/fault_handler: Fix pedantic warnings about signed/unsigned

This commit is contained in:
Joakim Nohlgård 2021-03-23 09:23:03 +01:00
parent f24e835c71
commit 821eb21861

View File

@ -23,7 +23,7 @@
#ifndef FORBIDDEN_ADDRESS #ifndef FORBIDDEN_ADDRESS
/* Many platforms do not allow writes to address 0x00000000 */ /* Many platforms do not allow writes to address 0x00000000 */
#define FORBIDDEN_ADDRESS (0x00000000) #define FORBIDDEN_ADDRESS (0x00000000u)
#endif /* !defined(FORBIDDEN_ADDRESS) */ #endif /* !defined(FORBIDDEN_ADDRESS) */
#ifndef INVALID_INSTRUCTION #ifndef INVALID_INSTRUCTION
/* Random garbage may crash the program as well. */ /* Random garbage may crash the program as well. */
@ -38,16 +38,16 @@ int main(void)
puts("Fault handler test application"); puts("Fault handler test application");
printf("This application will crash by attempting to write to address 0x%08x\n", FORBIDDEN_ADDRESS); printf("This application will crash by attempting to write to address 0x%08x\n", FORBIDDEN_ADDRESS);
puts("Waiting 1 second before crashing..."); puts("Waiting 1 second before crashing...");
xtimer_usleep(1000000); xtimer_usleep(1000000lu);
puts("Write to forbidden address " PRINT_MACRO(FORBIDDEN_ADDRESS)); puts("Write to forbidden address " PRINT_MACRO(FORBIDDEN_ADDRESS));
*((volatile int *) FORBIDDEN_ADDRESS) = 12345; *((volatile unsigned int *) FORBIDDEN_ADDRESS) = 12345u;
int readback = *((volatile int *) FORBIDDEN_ADDRESS); unsigned int readback = *((volatile unsigned int *) FORBIDDEN_ADDRESS);
printf("readback: 0x%08x\n", readback); printf("readback: 0x%08x\n", readback);
puts("We did not expect the application to survive the previous write."); puts("We did not expect the application to survive the previous write.");
puts("Trying to execute an invalid instruction"); puts("Trying to execute an invalid instruction");
puts(PRINT_MACRO(INVALID_INSTRUCTION)); puts(PRINT_MACRO(INVALID_INSTRUCTION));
INVALID_INSTRUCTION; INVALID_INSTRUCTION;
puts("Failed to crash the program, hanging..."); puts("Failed to crash the program, hanging...");
while(1); while(1) {}
return 0; return 0;
} }