summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2023-09-09 15:24:52 +0100
committerGitHub <noreply@github.com>2023-09-09 10:24:52 -0400
commit7235af2249843fb68740111b70089bad827a4730 (patch)
treeb5bb0ea1ba5e6c0b817fe218f350e4e60fbf833b /src/code
parentbedf07d5412f52cc05165b2d081578924cdd489d (diff)
Apply noreturn attribute where applicable (#1532)
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_800D31A0.c2
-rw-r--r--src/code/fault.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/code/code_800D31A0.c b/src/code/code_800D31A0.c
index 6bfa18d97..a6540c429 100644
--- a/src/code/code_800D31A0.c
+++ b/src/code/code_800D31A0.c
@@ -3,7 +3,7 @@
u32 gIsCtrlr2Valid = false;
-void func_800D31A0(void) {
+NORETURN void func_800D31A0(void) {
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
while (true) {
Sleep_Msec(1000);
diff --git a/src/code/fault.c b/src/code/fault.c
index 97aeaa75d..593613f50 100644
--- a/src/code/fault.c
+++ b/src/code/fault.c
@@ -1304,19 +1304,25 @@ void Fault_HungupFaultClient(const char* exp1, const char* exp2) {
* error occurs. The parameters specify two messages detailing the error, one
* or both may be NULL.
*/
-void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
+NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
FaultClient client;
s32 pad;
Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2);
*(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access
+
+ // Since the above line triggers an exception and transfers execution to the fault handler
+ // this function does not return and the rest of the function is unreachable.
+#ifdef __GNUC__
+ __builtin_unreachable();
+#endif
}
/**
* Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing
* filename and line number
*/
-void Fault_AddHungupAndCrash(const char* file, s32 line) {
+NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) {
char msg[256];
sprintf(msg, "HungUp %s:%d", file, line);