From d0bb8afe41d8686ef6e3010d426157fc2a38db62 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Feb 2024 11:38:10 -0800 Subject: [PATCH] Small cleanup (#62) --- src/io/contpfs.c | 14 +++++++------- src/io/controller.h | 23 +++++++++++------------ src/io/pfsallocatefile.c | 2 +- src/io/pfschecker.c | 6 +++--- src/io/pfsdeletefile.c | 8 ++++---- src/io/pfsfilestate.c | 6 +++--- src/io/pfsfreeblocks.c | 4 ++-- src/io/pfsnumfiles.c | 6 +++--- src/io/pfsreadwritefile.c | 8 ++++---- src/io/pfsreformat.c | 2 +- src/io/pfsrepairid.c | 2 +- src/io/pfssearchfile.c | 2 +- src/io/pfssetlabel.c | 4 ++-- 13 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/io/contpfs.c b/src/io/contpfs.c index 2632193b..c845a7d5 100644 --- a/src/io/contpfs.c +++ b/src/io/contpfs.c @@ -56,7 +56,7 @@ s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) { #if BUILD_VERSION >= VERSION_J j = 0; #else - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #endif newid->repaired = -1; @@ -65,7 +65,7 @@ s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) { newid->serial_low = badid->serial_low; #if BUILD_VERSION >= VERSION_J - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #else j = 0; #endif @@ -105,7 +105,7 @@ s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) { } while (j < PFS_MAX_BANKS); #if BUILD_VERSION >= VERSION_J - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #else ERRCK(SELECT_BANK(pfs, 0)); #endif @@ -147,7 +147,7 @@ s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) { int i; int j; - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); index[0] = PFS_ID_0AREA; index[1] = PFS_ID_1AREA; index[2] = PFS_ID_2AREA; @@ -184,7 +184,7 @@ s32 __osGetId(OSPfs* pfs) { s32 ret; __OSPackId* id; - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp)); __osIdCheckSum((u16*)temp, &sum, &isum); id = (__OSPackId*)temp; @@ -247,7 +247,7 @@ s32 __osCheckId(OSPfs* pfs) { } } #else - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #endif ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp); @@ -287,7 +287,7 @@ s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) { } #endif - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); offset = (bank > 0) ? 1 : pfs->inode_start_page; diff --git a/src/io/controller.h b/src/io/controller.h index 97889e03..5dac7f5c 100644 --- a/src/io/controller.h +++ b/src/io/controller.h @@ -251,36 +251,35 @@ extern u8 __osMaxControllers; #define SELECT_BANK(pfs, bank) \ __osPfsSelectBank((pfs), (bank)) -#define SET_ACTIVEBANK_TO_ZERO \ - if (pfs->activebank != 0) \ - { \ +#define SET_ACTIVEBANK_TO_ZERO() \ + if (pfs->activebank != 0) \ + { \ ERRCK(__osPfsSelectBank(pfs, 0)); \ } (void)0 #else #define SELECT_BANK(pfs, bank) \ - (pfs->activebank = (bank), \ - __osPfsSelectBank((pfs))) \ + (pfs->activebank = (bank), __osPfsSelectBank((pfs))) -#define SET_ACTIVEBANK_TO_ZERO \ - if (pfs->activebank != 0) \ - { \ - pfs->activebank = 0; \ +#define SET_ACTIVEBANK_TO_ZERO() \ + if (pfs->activebank != 0) \ + { \ + pfs->activebank = 0; \ ERRCK(__osPfsSelectBank(pfs)); \ } (void)0 #endif -#define PFS_CHECK_ID \ +#define PFS_CHECK_ID() \ if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ return PFS_ERR_NEW_PACK -#define PFS_CHECK_STATUS \ +#define PFS_CHECK_STATUS() \ if ((pfs->status & PFS_INITIALIZED) == 0) \ return PFS_ERR_INVALID -#define PFS_GET_STATUS \ +#define PFS_GET_STATUS() \ __osSiGetAccess(); \ ret = __osPfsGetStatus(queue, channel); \ __osSiRelAccess(); \ diff --git a/src/io/pfsallocatefile.c b/src/io/pfsallocatefile.c index da7d7939..24f6fe7c 100644 --- a/src/io/pfsallocatefile.c +++ b/src/io/pfsallocatefile.c @@ -178,7 +178,7 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name return PFS_ERR_INVALID; } - PFS_CHECK_ID; + PFS_CHECK_ID(); if (((ret = osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, file_no)) != 0) && ret != PFS_ERR_INVALID) { diff --git a/src/io/pfschecker.c b/src/io/pfschecker.c index 980e68e9..b7362000 100644 --- a/src/io/pfschecker.c +++ b/src/io/pfschecker.c @@ -76,7 +76,7 @@ s32 osPfsChecker(OSPfs* pfs) { if (cc != 0 || next_page.ipage != PFS_EOF) { bzero(&tmp_dir, sizeof(__OSDir)); - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); fixed++; } @@ -111,7 +111,7 @@ s32 osPfsChecker(OSPfs* pfs) { tmp_dir.status = DIR_STATUS_EMPTY; tmp_dir.data_sum = 0; - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); fixed++; } @@ -123,7 +123,7 @@ s32 osPfsChecker(OSPfs* pfs) { tmp_dir.status = DIR_STATUS_EMPTY; tmp_dir.data_sum = 0; - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); fixed++; } diff --git a/src/io/pfsdeletefile.c b/src/io/pfsdeletefile.c index 065bf269..e0132119 100644 --- a/src/io/pfsdeletefile.c +++ b/src/io/pfsdeletefile.c @@ -22,11 +22,11 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, #if BUILD_VERSION >= VERSION_J ERRCK(osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, &file_no)); - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #else - PFS_CHECK_STATUS; - PFS_CHECK_ID; - SET_ACTIVEBANK_TO_ZERO; + PFS_CHECK_STATUS(); + PFS_CHECK_ID(); + SET_ACTIVEBANK_TO_ZERO(); ERRCK(osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, &file_no)); if (file_no == -1) { diff --git a/src/io/pfsfilestate.c b/src/io/pfsfilestate.c index 1878907a..4f800208 100644 --- a/src/io/pfsfilestate.c +++ b/src/io/pfsfilestate.c @@ -19,13 +19,13 @@ s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) { return PFS_ERR_INVALID; } - PFS_CHECK_STATUS; + PFS_CHECK_STATUS(); #if BUILD_VERSION >= VERSION_J ERRCK(__osCheckId(pfs)); #else - PFS_CHECK_ID; + PFS_CHECK_ID(); #endif - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); diff --git a/src/io/pfsfreeblocks.c b/src/io/pfsfreeblocks.c index 28f00119..68a54c61 100644 --- a/src/io/pfsfreeblocks.c +++ b/src/io/pfsfreeblocks.c @@ -9,11 +9,11 @@ s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) { u8 bank; int offset; - PFS_CHECK_STATUS; + PFS_CHECK_STATUS(); #if BUILD_VERSION >= VERSION_J ERRCK(__osCheckId(pfs)); #else - PFS_CHECK_ID; + PFS_CHECK_ID(); #endif for (bank = 0; bank < pfs->banks; bank++) { ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); diff --git a/src/io/pfsnumfiles.c b/src/io/pfsnumfiles.c index c9d3b876..7fa352e4 100644 --- a/src/io/pfsnumfiles.c +++ b/src/io/pfsnumfiles.c @@ -7,13 +7,13 @@ s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used) { __OSDir dir; int files = 0; - PFS_CHECK_STATUS; + PFS_CHECK_STATUS(); #if BUILD_VERSION >= VERSION_J ERRCK(__osCheckId(pfs)); #else - PFS_CHECK_ID; + PFS_CHECK_ID(); #endif - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); for (j = 0; j < pfs->dir_size; j++) { ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)); diff --git a/src/io/pfsreadwritefile.c b/src/io/pfsreadwritefile.c index 4650dc0a..17afe547 100644 --- a/src/io/pfsreadwritefile.c +++ b/src/io/pfsreadwritefile.c @@ -45,9 +45,9 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in return PFS_ERR_INVALID; } - PFS_CHECK_STATUS; - PFS_CHECK_ID; - SET_ACTIVEBANK_TO_ZERO; + PFS_CHECK_STATUS(); + PFS_CHECK_ID(); + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); if (dir.company_code == 0 || dir.game_code == 0) { @@ -108,7 +108,7 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in if (flag == PFS_WRITE && (dir.status & DIR_STATUS_OCCUPIED) == 0) { dir.status |= DIR_STATUS_OCCUPIED; #if BUILD_VERSION >= VERSION_J - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); #else ERRCK(SELECT_BANK(pfs, 0)); #endif diff --git a/src/io/pfsreformat.c b/src/io/pfsreformat.c index 7cd63910..687b4564 100644 --- a/src/io/pfsreformat.c +++ b/src/io/pfsreformat.c @@ -23,7 +23,7 @@ s32 osPfsReFormat(OSPfs* pfs, OSMesgQueue* queue, int channel) { __osSiRelAccess(); ERRCK(__osGetId(pfs)); - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); for (j = 0; j < ARRLEN(tmp_data); j++) { tmp_data[j] = 0; diff --git a/src/io/pfsrepairid.c b/src/io/pfsrepairid.c index 3fec2a96..348f8b20 100644 --- a/src/io/pfsrepairid.c +++ b/src/io/pfsrepairid.c @@ -30,7 +30,7 @@ s32 osPfsRepairId(OSPfs *pfs) { s32 ret; __OSPackId *id; - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)&temp)); __osIdCheckSum((u16*)&temp, &sum, &isum); id = (__OSPackId*)&temp; diff --git a/src/io/pfssearchfile.c b/src/io/pfssearchfile.c index 351cd726..4fa3c57e 100644 --- a/src/io/pfssearchfile.c +++ b/src/io/pfssearchfile.c @@ -14,7 +14,7 @@ s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8 } ERRCK(__osCheckId(pfs)); #else - PFS_CHECK_ID; + PFS_CHECK_ID(); #endif for (j = 0; j < pfs->dir_size; j++) { diff --git a/src/io/pfssetlabel.c b/src/io/pfssetlabel.c index 967b37f2..43308c7d 100644 --- a/src/io/pfssetlabel.c +++ b/src/io/pfssetlabel.c @@ -12,7 +12,7 @@ s32 osPfsSetLabel(OSPfs* pfs, u8* label) { ERRCK(__osCheckId(pfs)); #else - PFS_CHECK_ID; + PFS_CHECK_ID(); #endif if (label != NULL) { @@ -34,7 +34,7 @@ s32 osPfsSetLabel(OSPfs* pfs, u8* label) { } return ret; #else - SET_ACTIVEBANK_TO_ZERO; + SET_ACTIVEBANK_TO_ZERO(); ERRCK(__osContRamWrite(pfs->queue, pfs->channel, PFS_LABEL_AREA, pfs->label, FALSE)); return 0; #endif