rosalina: cleanup variable names

This commit is contained in:
TuxSH 2020-05-15 20:00:13 +01:00
parent 9ae913064c
commit 71cddef78f
13 changed files with 67 additions and 60 deletions

View File

@ -60,8 +60,9 @@ typedef struct Menu {
MenuItem items[0x40]; MenuItem items[0x40];
} Menu; } Menu;
extern bool terminationRequest; extern bool menuShouldExit;
extern Handle terminationRequestEvent; extern bool preTerminationRequested;
extern Handle preTerminationEvent;
extern u32 menuCombo; extern u32 menuCombo;

View File

@ -32,7 +32,7 @@
#include "fmt.h" #include "fmt.h"
#include "ifile.h" #include "ifile.h"
extern Handle terminationRequestEvent; extern Handle preTerminationEvent;
static inline void assertSuccess(Result res) static inline void assertSuccess(Result res)
{ {
@ -254,7 +254,7 @@ void ERRF_HandleCommands(void)
{ {
ERRF_GetErrInfo(&info, (cmdbuf + 1), sizeof(ERRF_FatalErrInfo)); ERRF_GetErrInfo(&info, (cmdbuf + 1), sizeof(ERRF_FatalErrInfo));
ERRF_SaveErrorToFile(&info); ERRF_SaveErrorToFile(&info);
if(info.type != ERRF_ERRTYPE_LOGGED || info.procId == 0) if(!menuShouldExit && (info.type != ERRF_ERRTYPE_LOGGED || info.procId == 0))
{ {
menuEnter(); menuEnter();
@ -321,7 +321,7 @@ void errDispThreadMain(void)
do do
{ {
handles[0] = terminationRequestEvent; handles[0] = preTerminationEvent;
handles[1] = serverHandle; handles[1] = serverHandle;
handles[2] = sessionHandle; handles[2] = sessionHandle;
@ -365,7 +365,7 @@ void errDispThreadMain(void)
} }
} }
} }
while(!terminationRequest); while(!preTerminationRequested);
svcCloseHandle(sessionHandle); svcCloseHandle(sessionHandle);
svcCloseHandle(clientHandle); svcCloseHandle(clientHandle);

View File

@ -9,15 +9,15 @@
#include "gdb/net.h" #include "gdb/net.h"
#include "gdb/debug.h" #include "gdb/debug.h"
extern Handle terminationRequestEvent; extern Handle preTerminationEvent;
extern bool terminationRequest; extern bool preTerminationRequested;
void GDB_RunMonitor(GDBServer *server) void GDB_RunMonitor(GDBServer *server)
{ {
Handle handles[3 + MAX_DEBUG]; Handle handles[3 + MAX_DEBUG];
Result r = 0; Result r = 0;
handles[0] = terminationRequestEvent; handles[0] = preTerminationEvent;
handles[1] = server->super.shall_terminate_event; handles[1] = server->super.shall_terminate_event;
handles[2] = server->statusUpdated; handles[2] = server->statusUpdated;
@ -81,5 +81,5 @@ void GDB_RunMonitor(GDBServer *server)
RecursiveLock_Unlock(&ctx->lock); RecursiveLock_Unlock(&ctx->lock);
} }
} }
while(!terminationRequest && server->super.running); while(!preTerminationRequested && server->super.running);
} }

View File

@ -113,7 +113,7 @@ void inputRedirectionThreadMain(void)
char buf[20]; char buf[20];
u32 oldSpecialButtons = 0, specialButtons = 0; u32 oldSpecialButtons = 0, specialButtons = 0;
while(inputRedirectionEnabled && !terminationRequest) while(inputRedirectionEnabled && !preTerminationRequested)
{ {
struct pollfd pfd; struct pollfd pfd;
pfd.fd = sock; pfd.fd = sock;

View File

@ -155,8 +155,9 @@ void initSystem(void)
srvSetBlockingPolicy(true); // GetServiceHandle nonblocking if service port is full srvSetBlockingPolicy(true); // GetServiceHandle nonblocking if service port is full
} }
bool terminationRequest = false; bool menuShouldExit = false;
Handle terminationRequestEvent; bool preTerminationRequested = false;
Handle preTerminationEvent;
extern bool isHidInitialized; extern bool isHidInitialized;
static void handleTermNotification(u32 notificationId) static void handleTermNotification(u32 notificationId)
@ -188,8 +189,9 @@ static void handlePreTermNotification(u32 notificationId)
hidExit(); hidExit();
// Termination request // Termination request
terminationRequest = true; menuShouldExit = true;
svcSignalEvent(terminationRequestEvent); preTerminationRequested = true;
svcSignalEvent(preTerminationEvent);
Draw_Unlock(); Draw_Unlock();
} }
@ -232,7 +234,7 @@ int main(void)
bufPtrs[2] = IPC_Desc_StaticBuffer(sizeof(ldrArgvBuf), 1); bufPtrs[2] = IPC_Desc_StaticBuffer(sizeof(ldrArgvBuf), 1);
bufPtrs[3] = (u32)ldrArgvBuf; bufPtrs[3] = (u32)ldrArgvBuf;
if(R_FAILED(svcCreateEvent(&terminationRequestEvent, RESET_STICKY))) if(R_FAILED(svcCreateEvent(&preTerminationEvent, RESET_STICKY)))
svcBreak(USERBREAK_ASSERT); svcBreak(USERBREAK_ASSERT);
Draw_Init(); Draw_Init();

View File

@ -61,7 +61,7 @@ u32 waitInputWithTimeout(s32 msec)
{ {
svcSleepThread(1 * 1000 * 1000LL); svcSleepThread(1 * 1000 * 1000LL);
Draw_Lock(); Draw_Lock();
if (!isHidInitialized || terminationRequest) if (!isHidInitialized || menuShouldExit)
{ {
keys = 0; keys = 0;
Draw_Unlock(); Draw_Unlock();
@ -72,7 +72,7 @@ u32 waitInputWithTimeout(s32 msec)
hidScanInput(); hidScanInput();
keys = convertHidKeys(hidKeysDown()) | (convertHidKeys(hidKeysDownRepeat()) & DIRECTIONAL_KEYS); keys = convertHidKeys(hidKeysDown()) | (convertHidKeys(hidKeysDownRepeat()) & DIRECTIONAL_KEYS);
Draw_Unlock(); Draw_Unlock();
} while (keys == 0 && !terminationRequest && isHidInitialized && (msec < 0 || n < msec)); } while (keys == 0 && !menuShouldExit && isHidInitialized && (msec < 0 || n < msec));
return keys; return keys;
@ -89,7 +89,7 @@ static u32 scanHeldKeys(void)
Draw_Lock(); Draw_Lock();
if (!isHidInitialized || terminationRequest) if (!isHidInitialized || menuShouldExit)
keys = 0; keys = 0;
else else
{ {
@ -108,13 +108,13 @@ u32 waitComboWithTimeout(s32 msec)
u32 tempKeys = 0; u32 tempKeys = 0;
// Wait for nothing to be pressed // Wait for nothing to be pressed
while (scanHeldKeys() != 0 && !terminationRequest && isHidInitialized && (msec < 0 || n < msec)) while (scanHeldKeys() != 0 && !menuShouldExit && isHidInitialized && (msec < 0 || n < msec))
{ {
svcSleepThread(1 * 1000 * 1000LL); svcSleepThread(1 * 1000 * 1000LL);
n++; n++;
} }
if (terminationRequest || !isHidInitialized || !(msec < 0 || n < msec)) if (menuShouldExit || !isHidInitialized || !(msec < 0 || n < msec))
return 0; return 0;
do do
@ -130,7 +130,7 @@ u32 waitComboWithTimeout(s32 msec)
if (i == 1) keys = tempKeys; if (i == 1) keys = tempKeys;
} }
} }
while((keys == 0 || scanHeldKeys() != 0) && !terminationRequest && isHidInitialized && (msec < 0 || n < msec)); while((keys == 0 || scanHeldKeys() != 0) && !menuShouldExit && isHidInitialized && (msec < 0 || n < msec));
return keys; return keys;
} }
@ -171,8 +171,11 @@ void menuThreadMain(void)
hidInit(); // assume this doesn't fail hidInit(); // assume this doesn't fail
isHidInitialized = true; isHidInitialized = true;
while(!terminationRequest) while(!preTerminationRequested)
{ {
if (menuShouldExit)
continue;
Cheat_ApplyCheats(); Cheat_ApplyCheats();
if((scanHeldKeys() & menuCombo) == menuCombo) if((scanHeldKeys() & menuCombo) == menuCombo)
@ -191,8 +194,9 @@ static s32 menuRefCount = 0;
void menuEnter(void) void menuEnter(void)
{ {
Draw_Lock(); Draw_Lock();
if(menuRefCount++ == 0) if(!menuShouldExit && menuRefCount == 0)
{ {
menuRefCount++;
svcKernelSetState(0x10000, 1); svcKernelSetState(0x10000, 1);
svcSleepThread(5 * 1000 * 100LL); svcSleepThread(5 * 1000 * 100LL);
if (Draw_AllocateFramebufferCache() == 0) if (Draw_AllocateFramebufferCache() == 0)
@ -372,5 +376,5 @@ void menuShow(Menu *root)
menuDraw(currentMenu, selectedItem); menuDraw(currentMenu, selectedItem);
Draw_Unlock(); Draw_Unlock();
} }
while(!terminationRequest); while(!menuShouldExit);
} }

View File

@ -89,7 +89,7 @@ void RosalinaMenu_ShowCredits(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void RosalinaMenu_Reboot(void) void RosalinaMenu_Reboot(void)
@ -117,7 +117,7 @@ void RosalinaMenu_Reboot(void)
} else if(pressed & KEY_B) } else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
void RosalinaMenu_PowerOff(void) // Soft shutdown. void RosalinaMenu_PowerOff(void) // Soft shutdown.
@ -146,7 +146,7 @@ void RosalinaMenu_PowerOff(void) // Soft shutdown.
else if(pressed & KEY_B) else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
@ -310,7 +310,7 @@ end:
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
#undef TRY #undef TRY
} }

View File

@ -1944,7 +1944,7 @@ void RosalinaMenu_Cheats(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} while (!(waitInput() & KEY_B) && !terminationRequest); } while (!(waitInput() & KEY_B) && !menuShouldExit);
} }
else else
{ {
@ -1982,14 +1982,14 @@ void RosalinaMenu_Cheats(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
if (terminationRequest) break; if (menuShouldExit) break;
u32 pressed; u32 pressed;
do do
{ {
pressed = waitInputWithTimeout(50); pressed = waitInputWithTimeout(50);
if (pressed != 0) break; if (pressed != 0) break;
} while (pressed == 0 && !terminationRequest); } while (pressed == 0 && !menuShouldExit);
if (pressed & KEY_B) if (pressed & KEY_B)
break; break;
@ -2025,7 +2025,7 @@ void RosalinaMenu_Cheats(void)
pagePrev = page; pagePrev = page;
page = selected / CHEATS_PER_MENU_PAGE; page = selected / CHEATS_PER_MENU_PAGE;
} while (!terminationRequest); } while (!menuShouldExit);
} }
} }

View File

@ -139,13 +139,13 @@ void DebuggerMenu_EnableDebugger(void)
if(!done) if(!done)
{ {
res = GDB_InitializeServer(&gdbServer); res = GDB_InitializeServer(&gdbServer);
Handle handles[3] = { gdbServer.super.started_event, gdbServer.super.shall_terminate_event, terminationRequestEvent }; Handle handles[3] = { gdbServer.super.started_event, gdbServer.super.shall_terminate_event, preTerminationEvent };
s32 idx; s32 idx;
if(R_SUCCEEDED(res)) if(R_SUCCEEDED(res))
{ {
debuggerCreateSocketThread(); debuggerCreateSocketThread();
debuggerCreateDebugThread(); debuggerCreateDebugThread();
res = svcWaitSynchronizationN(&idx, handles, 3, false, 10 * 1000 * 1000 * 1000LL); res = svcWaitSynchronizationN(&idx, handles, 3, false, 5 * 1000 * 1000 * 1000LL);
if(res == 0) res = gdbServer.super.init_result; if(res == 0) res = gdbServer.super.init_result;
} }
@ -162,7 +162,7 @@ void DebuggerMenu_EnableDebugger(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void DebuggerMenu_DisableDebugger(void) void DebuggerMenu_DisableDebugger(void)
@ -183,7 +183,7 @@ void DebuggerMenu_DisableDebugger(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void DebuggerMenu_DebugNextApplicationByForce(void) void DebuggerMenu_DebugNextApplicationByForce(void)
@ -232,7 +232,7 @@ void DebuggerMenu_DebugNextApplicationByForce(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void debuggerSocketThreadMain(void) void debuggerSocketThreadMain(void)

View File

@ -95,7 +95,7 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
static void MiscellaneousMenu_ConvertComboToString(char *out, u32 combo) static void MiscellaneousMenu_ConvertComboToString(char *out, u32 combo)
@ -161,7 +161,7 @@ void MiscellaneousMenu_ChangeMenuCombo(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void MiscellaneousMenu_SaveSettings(void) void MiscellaneousMenu_SaveSettings(void)
@ -227,7 +227,7 @@ void MiscellaneousMenu_SaveSettings(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void MiscellaneousMenu_InputRedirection(void) void MiscellaneousMenu_InputRedirection(void)
@ -327,7 +327,7 @@ void MiscellaneousMenu_InputRedirection(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
} }
void MiscellaneousMenu_SyncTimeDate(void) void MiscellaneousMenu_SyncTimeDate(void)
@ -368,7 +368,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(input & (KEY_A | KEY_B)) && !terminationRequest); while(!(input & (KEY_A | KEY_B)) && !menuShouldExit);
if (input & KEY_B) if (input & KEY_B)
return; return;
@ -410,6 +410,6 @@ void MiscellaneousMenu_SyncTimeDate(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(input & KEY_B) && !terminationRequest); while(!(input & KEY_B) && !menuShouldExit);
} }

View File

@ -197,7 +197,7 @@ end:
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
} }
while(!(waitInput() & KEY_B) && !terminationRequest); while(!(waitInput() & KEY_B) && !menuShouldExit);
#undef TRY #undef TRY
} }
@ -568,7 +568,7 @@ static void ProcessListMenu_MemoryViewer(const ProcessInfo *info)
if(menus[menuMode].selected >= menus[menuMode].max) if(menus[menuMode].selected >= menus[menuMode].max)
menus[menuMode].selected = menus[menuMode].max - 1; menus[menuMode].selected = menus[menuMode].max - 1;
} }
while(!terminationRequest); while(!menuShouldExit);
clearMenu(); clearMenu();
} }
@ -685,7 +685,7 @@ void RosalinaMenu_ProcessList(void)
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
if(terminationRequest) if(menuShouldExit)
break; break;
u32 pressed; u32 pressed;
@ -698,7 +698,7 @@ void RosalinaMenu_ProcessList(void)
if(memcmp(infos, infosPrev, sizeof(infos)) != 0) if(memcmp(infos, infosPrev, sizeof(infos)) != 0)
break; break;
} }
while(pressed == 0 && !terminationRequest); while(pressed == 0 && !menuShouldExit);
if(pressed & KEY_B) if(pressed & KEY_B)
break; break;
@ -728,5 +728,5 @@ void RosalinaMenu_ProcessList(void)
pagePrev = page; pagePrev = page;
page = selected / PROCESSES_PER_MENU_PAGE; page = selected / PROCESSES_PER_MENU_PAGE;
} }
while(!terminationRequest); while(!menuShouldExit);
} }

View File

@ -78,7 +78,7 @@ void SysConfigMenu_ToggleLEDs(void)
else if(pressed & KEY_B) else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
void SysConfigMenu_ToggleWireless(void) void SysConfigMenu_ToggleWireless(void)
@ -148,7 +148,7 @@ void SysConfigMenu_ToggleWireless(void)
else if(pressed & KEY_B) else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
void SysConfigMenu_UpdateStatus(bool control) void SysConfigMenu_UpdateStatus(bool control)
@ -227,7 +227,7 @@ static bool SysConfigMenu_ForceWifiConnection(int slot)
if(pressed & KEY_B) if(pressed & KEY_B)
break; break;
} }
while(!terminationRequest); while(!menuShouldExit);
return forcedConnection; return forcedConnection;
} }
@ -270,7 +270,7 @@ void SysConfigMenu_TogglePowerButton(void)
else if(pressed & KEY_B) else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
void SysConfigMenu_ControlWifi(void) void SysConfigMenu_ControlWifi(void)
@ -332,7 +332,7 @@ void SysConfigMenu_ControlWifi(void)
else if(pressed & KEY_B) else if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }
void SysConfigMenu_DisableForcedWifiConnection(void) void SysConfigMenu_DisableForcedWifiConnection(void)
@ -355,5 +355,5 @@ void SysConfigMenu_DisableForcedWifiConnection(void)
if(pressed & KEY_B) if(pressed & KEY_B)
return; return;
} }
while(!terminationRequest); while(!menuShouldExit);
} }

View File

@ -14,8 +14,8 @@
#include "minisoc.h" #include "minisoc.h"
#include "sock_util.h" #include "sock_util.h"
extern Handle terminationRequestEvent; extern Handle preTerminationEvent;
extern bool terminationRequest; extern bool preTerminationRequested;
// soc's poll function is odd, and doesn't like -1 as fd. // soc's poll function is odd, and doesn't like -1 as fd.
// so this compacts everything together // so this compacts everything together
@ -104,7 +104,7 @@ Result server_init(struct sock_server *serv)
Result server_bind(struct sock_server *serv, u16 port) Result server_bind(struct sock_server *serv, u16 port)
{ {
int server_sockfd; int server_sockfd;
Handle handles[2] = { terminationRequestEvent, serv->shall_terminate_event }; Handle handles[2] = { preTerminationEvent, serv->shall_terminate_event };
s32 idx = -1; s32 idx = -1;
server_sockfd = socSocket(AF_INET, SOCK_STREAM, 0); server_sockfd = socSocket(AF_INET, SOCK_STREAM, 0);
@ -163,7 +163,7 @@ Result server_bind(struct sock_server *serv, u16 port)
static bool server_should_exit(struct sock_server *serv) static bool server_should_exit(struct sock_server *serv)
{ {
return svcWaitSynchronization(serv->shall_terminate_event, 0) == 0 || svcWaitSynchronization(terminationRequestEvent, 0) == 0; return svcWaitSynchronization(serv->shall_terminate_event, 0) == 0 || svcWaitSynchronization(preTerminationEvent, 0) == 0;
} }
void server_run(struct sock_server *serv) void server_run(struct sock_server *serv)
@ -172,7 +172,7 @@ void server_run(struct sock_server *serv)
serv->running = true; serv->running = true;
svcSignalEvent(serv->started_event); svcSignalEvent(serv->started_event);
while(serv->running && !terminationRequest) while(serv->running && !preTerminationRequested)
{ {
if(server_should_exit(serv)) if(server_should_exit(serv))
goto abort_connections; goto abort_connections;