From 30bb85a4efac5f83ebcde7ba03288e74a9a8f14f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 11 May 2015 10:33:33 -0400 Subject: [PATCH] Get rid of basic warnings found with -Wextra - Signed/unsigned compares - static not being before const --- source/common.h | 4 ++-- source/draw.c | 5 +++-- source/gamecart/command_ntr.c | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/common.h b/source/common.h index 6497751..d0c9057 100644 --- a/source/common.h +++ b/source/common.h @@ -26,7 +26,7 @@ inline char* strupper(const char* str) { const size_t string_len = strlen(str); char* buffer = (char*)malloc(string_len + 1); - for (int i = 0; i < string_len; ++i) + for (size_t i = 0; i < string_len; ++i) buffer[i] = toupper((unsigned)str[i]); return buffer; @@ -36,7 +36,7 @@ inline char* strlower(const char* str) { const size_t string_len = strlen(str); char* buffer = (char*)malloc(string_len + 1); - for (int i = 0; i < string_len; ++i) + for (size_t i = 0; i < string_len; ++i) buffer[i] = tolower((unsigned)str[i]); return buffer; diff --git a/source/draw.c b/source/draw.c index 1e06cd9..d936b24 100644 --- a/source/draw.c +++ b/source/draw.c @@ -45,8 +45,9 @@ void DrawCharacter(unsigned char *screen, int character, int x, int y, int color void DrawString(unsigned char *screen, const char *str, int x, int y, int color, int bgcolor) { - int i; - for (i = 0; i < strlen(str); i++) + const size_t string_len = strlen(str); + + for (size_t i = 0; i < string_len; i++) DrawCharacter(screen, str[i], x + i * 8, y, color, bgcolor); } diff --git a/source/gamecart/command_ntr.c b/source/gamecart/command_ntr.c index dc6108f..d4b92c6 100644 --- a/source/gamecart/command_ntr.c +++ b/source/gamecart/command_ntr.c @@ -4,20 +4,20 @@ void NTR_CmdReset() { - const static u32 reset_cmd[2] = { 0x9F000000, 0x00000000 }; + static const u32 reset_cmd[2] = { 0x9F000000, 0x00000000 }; NTR_SendCommand(reset_cmd, 0x2000, NTRCARD_CLK_SLOW | NTRCARD_DELAY1(0x1FFF) | NTRCARD_DELAY2(0x18), NULL); } int NTR_CmdGetCartId() { - int id; - const static u32 getid_cmd[2] = { 0x90000000, 0x00000000 }; + int id; + static const u32 getid_cmd[2] = { 0x90000000, 0x00000000 }; NTR_SendCommand(getid_cmd, 0x4, NTRCARD_CLK_SLOW | NTRCARD_DELAY1(0x1FFF) | NTRCARD_DELAY2(0x18), &id); return id; } void NTR_CmdEnter16ByteMode() { - const static u32 enter16bytemode_cmd[2] = { 0x3E000000, 0x00000000 }; + static const u32 enter16bytemode_cmd[2] = { 0x3E000000, 0x00000000 }; NTR_SendCommand(enter16bytemode_cmd, 0x0, 0, NULL); }