From 8f3cba37b35a74d51f62613a5beca9c4da69603d Mon Sep 17 00:00:00 2001 From: Aurora Date: Wed, 14 Sep 2016 22:31:25 +0200 Subject: [PATCH] Minor stuff --- source/config.c | 11 ++++++----- source/crypto.c | 4 ++-- source/draw.c | 2 +- source/firm.c | 2 +- source/i2c.c | 4 ++-- source/memory.c | 6 +++--- source/patches.c | 4 ++-- source/pin.c | 6 +++--- source/strings.c | 4 ++-- source/utils.c | 6 +++--- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/source/config.c b/source/config.c index 983d0bd..906685a 100644 --- a/source/config.c +++ b/source/config.c @@ -139,14 +139,15 @@ void configMenu(bool oldPinStatus) "out-of-region games work.\n" "Refer to the wiki for instructions", - "Show the currently booted NAND in\n" - "System Settings (Sys = SysNAND,\n" - "Emu = EmuNAND 1, EmuX = EmuNAND X,\n" + "Show the currently booted NAND\n" + "(Sys = SysNAND, Emu = EmuNAND 1,\n" + "EmuX = EmuNAND X,\n" "SysE = SysNAND with EmuNAND 1 FIRM,\n" "SyEX = SysNAND with EmuNAND X FIRM,\n" "EmXS = EmuNAND X with SysNAND FIRM)\n" - "or an user-defined custom string\n" - "(refer to the wiki for instructions)", + "or an user-defined custom string in\n" + "System Settings.\n" + "Refer to the wiki for instructions", "Show the GBA boot screen when\n" "launching GBA games", diff --git a/source/crypto.c b/source/crypto.c index ee37fbb..4a8d297 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -405,7 +405,7 @@ void arm9Loader(u8 *arm9Section) //Firm keys u8 __attribute__((aligned(4))) keyY[0x10]; u8 __attribute__((aligned(4))) arm9BinCTR[0x10]; - u8 arm9BinSlot = a9lVersion ? 0x16 : 0x15; + u8 arm9BinSlot = a9lVersion != 0 ? 0x16 : 0x15; //Setup keys needed for arm9bin decryption memcpy(keyY, arm9Section + 0x10, 0x10); @@ -414,7 +414,7 @@ void arm9Loader(u8 *arm9Section) //Calculate the size of the ARM9 binary u32 arm9BinSize = 0; //http://stackoverflow.com/questions/12791077/atoi-implementation-in-c - for(u8 *tmp = arm9Section + 0x30; *tmp; tmp++) + for(u8 *tmp = arm9Section + 0x30; *tmp != 0; tmp++) arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + *tmp - '0'; if(a9lVersion) diff --git a/source/draw.c b/source/draw.c index dd5b0a8..0ee1030 100644 --- a/source/draw.c +++ b/source/draw.c @@ -63,7 +63,7 @@ void drawCharacter(char character, bool isTopScreen, u32 posX, u32 posY, u32 col char charPos = font[character * 8 + y]; for(u32 x = 0; x < 8; x++) - if((charPos >> (7 - x)) & 1) + if(((charPos >> (7 - x)) & 1) == 1) { u32 screenPos = (posX * SCREEN_HEIGHT * 3 + (SCREEN_HEIGHT - y - posY - 1) * 3) + x * 3 * SCREEN_HEIGHT; diff --git a/source/firm.c b/source/firm.c index 681d130..2344bc1 100755 --- a/source/firm.c +++ b/source/firm.c @@ -580,7 +580,7 @@ static inline void launchFirm(FirmwareType firmType) #endif //Copy FIRM sections to respective memory locations - for(; sectionNum < 4 && section[sectionNum].size; sectionNum++) + for(; sectionNum < 4 && section[sectionNum].size != 0; sectionNum++) memcpy(section[sectionNum].address, (u8 *)firm + section[sectionNum].offset, section[sectionNum].size); //Determine the ARM11 entry to use diff --git a/source/i2c.c b/source/i2c.c index f2b479d..3367034 100644 --- a/source/i2c.c +++ b/source/i2c.c @@ -117,8 +117,8 @@ static bool i2cSelectRegister(u8 bus_id, u8 reg) bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data) { - u8 bus_id = i2cGetDeviceBusId(dev_id); - u8 dev_addr = i2cGetDeviceRegAddr(dev_id); + u8 bus_id = i2cGetDeviceBusId(dev_id), + dev_addr = i2cGetDeviceRegAddr(dev_id); for(u32 i = 0; i < 8; i++) { diff --git a/source/memory.c b/source/memory.c index bb931a2..4e29635 100644 --- a/source/memory.c +++ b/source/memory.c @@ -46,13 +46,13 @@ void memset32(void *dest, u32 filler, u32 size) int memcmp(const void *buf1, const void *buf2, u32 size) { - const u8 *buf1c = (const u8 *)buf1; - const u8 *buf2c = (const u8 *)buf2; + const u8 *buf1c = (const u8 *)buf1, + *buf2c = (const u8 *)buf2; for(u32 i = 0; i < size; i++) { int cmp = buf1c[i] - buf2c[i]; - if(cmp) return cmp; + if(cmp != 0) return cmp; } return 0; diff --git a/source/patches.c b/source/patches.c index d5c8be8..ff09a2d 100644 --- a/source/patches.c +++ b/source/patches.c @@ -187,9 +187,9 @@ void implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u32 baseK11VA, u8 **fre else isRelease = rev[4] == 0; #ifdef DEV - info->flags = 1 /* dev branch */ | ((isRelease ? 1 : 0) << 1) /* is release */; + info->flags = 1 /* dev build */ | ((isRelease ? 1 : 0) << 1) /* is release */; #else - info->flags = 0 /* master branch */ | ((isRelease ? 1 : 0) << 1) /* is release */; + info->flags = 0 /* regular build */ | ((isRelease ? 1 : 0) << 1) /* is release */; #endif arm11SvcTable[0x2E] = baseK11VA + *freeK11Space - pos; //Stubbed svc diff --git a/source/pin.c b/source/pin.c index 89dd844..bfd8d34 100644 --- a/source/pin.c +++ b/source/pin.c @@ -59,7 +59,7 @@ void newPin(bool allowSkipping) u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0}; u8 cnt = 0; - int charDrawPos = 16 * SPACING_X; + u32 charDrawPos = 16 * SPACING_X; while(cnt < length) { @@ -130,12 +130,12 @@ bool verifyPin(void) bool unlock = false; u8 cnt = 0; - int charDrawPos = 16 * SPACING_X; + u32 charDrawPos = 16 * SPACING_X; const char *messagePath = "/luma/pinmessage.txt"; u32 messageSize = getFileSize(messagePath); - if(messageSize > 0 && messageSize < 800) + if(messageSize > 0 && messageSize <= 800) { char message[messageSize + 1]; fileRead(message, messagePath, 0); diff --git a/source/strings.c b/source/strings.c index 86e93ce..55fee26 100644 --- a/source/strings.c +++ b/source/strings.c @@ -34,7 +34,7 @@ u32 strlen(const char *string) void concatenateStrings(char *destination, const char *source) { - int i = strlen(source), + u32 i = strlen(source), j = strlen(destination); memcpy(&destination[j], source, i + 1); @@ -51,5 +51,5 @@ void hexItoa(u32 number, char *out, u32 digits) number >>= 4; } - for(; i < digits; i++) out[digits - 1 - i] = '0'; + while(i < digits) out[digits - 1 - i++] = '0'; } \ No newline at end of file diff --git a/source/utils.c b/source/utils.c index a76ddf8..e38bf27 100644 --- a/source/utils.c +++ b/source/utils.c @@ -29,8 +29,8 @@ u32 waitInput(void) { - u32 pressedKey = 0, - key; + bool pressedKey = false; + u32 key; //Wait for no keys to be pressed while(HID_PAD); @@ -46,7 +46,7 @@ u32 waitInput(void) for(u32 i = 0x13000; i > 0; i--) { if(key != HID_PAD) break; - if(i == 1) pressedKey = 1; + if(i == 1) pressedKey = true; } } while(!pressedKey);