From 8a54ea4823bb55d6e562d97f88da555813d946f0 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Thu, 23 Jul 2020 17:57:43 -0400 Subject: [PATCH] Supress unnecessary log messages. --- source/gamecard.c | 9 +++++++-- source/usb.c | 6 ++++-- source/utils.c | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/gamecard.c b/source/gamecard.c index 55b03b1..a7b775c 100644 --- a/source/gamecard.c +++ b/source/gamecard.c @@ -215,6 +215,8 @@ void gamecardExit(void) { mutexLock(&g_gamecardMutex); + if (!g_gamecardInterfaceInit) goto end; + /* Destroy gamecard detection thread. */ if (g_gameCardDetectionThreadCreated) { @@ -252,6 +254,7 @@ void gamecardExit(void) g_gamecardInterfaceInit = false; +end: mutexUnlock(&g_gamecardMutex); } @@ -822,7 +825,7 @@ static bool gamecardGetHandleAndStorage(u32 partition) rc = fsDeviceOperatorGetGameCardHandle(&g_deviceOperator, &g_gameCardHandle); if (R_FAILED(rc)) { - LOGFILE("fsDeviceOperatorGetGameCardHandle failed on try #%u! (0x%08X).", i + 1, rc); + //LOGFILE("fsDeviceOperatorGetGameCardHandle failed on try #%u! (0x%08X).", i + 1, rc); continue; } @@ -831,7 +834,7 @@ static bool gamecardGetHandleAndStorage(u32 partition) if (R_FAILED(rc)) { gamecardCloseHandle(); /* Close invalid gamecard handle. */ - LOGFILE("fsOpenGameCardStorage failed to open %s storage area on try #%u! (0x%08X).", GAMECARD_STORAGE_AREA_NAME(partition + 1), i + 1, rc); + //LOGFILE("fsOpenGameCardStorage failed to open %s storage area on try #%u! (0x%08X).", GAMECARD_STORAGE_AREA_NAME(partition + 1), i + 1, rc); continue; } @@ -839,6 +842,8 @@ static bool gamecardGetHandleAndStorage(u32 partition) break; } + if (R_FAILED(rc)) LOGFILE("fsDeviceOperatorGetGameCardHandle / fsOpenGameCardStorage failed! (0x%08X).", rc); + return R_SUCCEEDED(rc); } diff --git a/source/usb.c b/source/usb.c index a2b84c8..e02db5c 100644 --- a/source/usb.c +++ b/source/usb.c @@ -480,13 +480,15 @@ static u32 usbSendCommand(size_t cmd_size) if (!usbWrite(g_usbTransferBuffer, cmd_size)) { - LOGFILE("Failed to write 0x%lX bytes long block for type 0x%X command!", cmd_size, cmd); + /* Log error message only if the USB session has been started, or if thread exit flag hasn't been enabled. */ + if (g_usbSessionStarted || !g_usbDetectionThreadExitFlag) LOGFILE("Failed to write 0x%lX bytes long block for type 0x%X command!", cmd_size, cmd); return UsbStatusType_WriteCommandFailed; } if (!usbRead(g_usbTransferBuffer, sizeof(UsbStatus))) { - LOGFILE("Failed to read 0x%lX bytes long status block for type 0x%X command!", sizeof(UsbStatus), cmd); + /* Log error message only if the USB session has been started, or if thread exit flag hasn't been enabled. */ + if (g_usbSessionStarted || !g_usbDetectionThreadExitFlag) LOGFILE("Failed to read 0x%lX bytes long status block for type 0x%X command!", sizeof(UsbStatus), cmd); return UsbStatusType_ReadStatusFailed; } diff --git a/source/utils.c b/source/utils.c index b357b1c..1972224 100644 --- a/source/utils.c +++ b/source/utils.c @@ -148,6 +148,8 @@ void utilsCloseResources(void) { mutexLock(&g_resourcesMutex); + if (!g_resourcesInitialized) goto end; + /* Free LVGL resources. */ //lvglHelperExit(); @@ -183,6 +185,7 @@ void utilsCloseResources(void) g_resourcesInitialized = false; +end: mutexUnlock(&g_resourcesMutex); }