From ebae06003516f3d5bae02a12b8fa27b43c6276fe Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Fri, 14 Aug 2020 22:15:47 -0400 Subject: [PATCH] Cleaned up a few compiler and cppcheck warnings in code base. There are still quite a few more TODO. --- src/boards/emu2413.c | 4 ++-- src/boards/fk23c.cpp | 12 ++++++------ src/cheat.cpp | 4 ++-- src/conddebug.cpp | 4 ++-- src/debug.cpp | 2 +- src/drivers/common/cheat.cpp | 12 ++++++------ src/drivers/common/vidblit.cpp | 6 +++--- src/drivers/videolog/nesvideos-piece.cpp | 4 ++-- src/drivers/win/monitor.cpp | 2 +- src/drivers/win/ramwatch.cpp | 2 ++ src/drivers/win/window.cpp | 6 +++--- 11 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/boards/emu2413.c b/src/boards/emu2413.c index 5c8e7042..8b6035c8 100644 --- a/src/boards/emu2413.c +++ b/src/boards/emu2413.c @@ -604,8 +604,8 @@ void OPLL_reset(OPLL * opll) { for (i = 0; i < 0x40; i++) OPLL_writeReg(opll, i, 0); - opll->realstep = (uint32)((1 << 31) / rate); - opll->opllstep = (uint32)((1 << 31) / (clk / 72)); + opll->realstep = (uint32)((1u << 31) / rate); + opll->opllstep = (uint32)((1u << 31) / (clk / 72)); opll->oplltime = 0; } diff --git a/src/boards/fk23c.cpp b/src/boards/fk23c.cpp index d7b3889f..e0df71d2 100644 --- a/src/boards/fk23c.cpp +++ b/src/boards/fk23c.cpp @@ -82,10 +82,10 @@ static int prg_mask; //PRG wrapper static void BMCFK23CPW(uint32 A, uint8 V) { - uint32 bank = (EXPREGS[1] & 0x1F); - uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0); - uint32 block = (EXPREGS[1] & 0x60) | hiblock; - uint32 extra = (EXPREGS[3] & 2); + //uint32 bank = (EXPREGS[1] & 0x1F); + //uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0); + //uint32 block = (EXPREGS[1] & 0x60) | hiblock; + //uint32 extra = (EXPREGS[3] & 2); // FCEU_printf("0:%04X:%02X\n",A,V); if((EXPREGS[0]&7)==4) @@ -161,7 +161,7 @@ static DECLFW(BMCFK23CWrite) EXPREGS[A&3]=V; // BUT WHY is there any rom that need it actually? - bool remap = false; +// bool remap = false; // FCEU_printf("K3:(exp0=%02x)\n",EXPREGS[0]); // FCEU_printf("WH0:%04X:%02X\n",A,V); @@ -199,7 +199,7 @@ static void BMCFK23CReset(void) //this little hack makes sure that we try all the dip switch settings eventually, if we reset enough dipswitch++; dipswitch&=7; - printf("BMCFK23C dipswitch set to %d\n",dipswitch); + printf("BMCFK23C dipswitch set to %u\n",dipswitch); EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0; EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF; diff --git a/src/cheat.cpp b/src/cheat.cpp index 3934e73d..fe2db821 100644 --- a/src/cheat.cpp +++ b/src/cheat.cpp @@ -569,7 +569,7 @@ int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c) int FCEUI_DecodePAR(const char *str, int *a, int *v, int *c, int *type) { - int boo[4]; + unsigned int boo[4]; if(strlen(str)!=8) return(0); sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3); @@ -932,4 +932,4 @@ inline void FCEUI_ReleaseCheatMap() free(cheatMap); cheatMap = NULL; } -} \ No newline at end of file +} diff --git a/src/conddebug.cpp b/src/conddebug.cpp index 915fcfde..c08519c8 100644 --- a/src/conddebug.cpp +++ b/src/conddebug.cpp @@ -194,10 +194,10 @@ Condition* Parentheses(const char** str, Condition* c, char openPar, char closeP { scan(str); - c->lhs = Connect(str); - if (!c) return 0; + c->lhs = Connect(str); + if (next == closePar) { scan(str); diff --git a/src/debug.cpp b/src/debug.cpp index c88e581a..47e873ed 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -22,7 +22,7 @@ int offsetStringToInt(unsigned int type, const char* offsetBuffer) { int offset = -1; - if (sscanf(offsetBuffer,"%4X",&offset) == EOF) + if (sscanf(offsetBuffer,"%4X",(unsigned int *)&offset) == EOF) { return -1; } diff --git a/src/drivers/common/cheat.cpp b/src/drivers/common/cheat.cpp index f985876e..2cff0cd6 100644 --- a/src/drivers/common/cheat.cpp +++ b/src/drivers/common/cheat.cpp @@ -226,7 +226,7 @@ static void ModifyCheat(int num) printf("Address [$%04x]: ",(unsigned int)A); A=GetH16(A); - printf("Value [%03d]: ",(unsigned int)V); + printf("Value [%03u]: ",(unsigned int)V); V=Get8(V); printf("Compare [%3d]: ",compare); @@ -302,9 +302,9 @@ static void AddCheatParam(uint32 A, uint8 V) GetString(name,256); printf("Address [$%04x]: ",(unsigned int)A); A=GetH16(A); - printf("Value [%03d]: ",(unsigned int)V); + printf("Value [%03u]: ",(unsigned int)V); V=Get8(V); - printf("Add cheat \"%s\" for address $%04x with value %03d?",name,(unsigned int)A,(unsigned int)V); + printf("Add cheat \"%s\" for address $%04x with value %03u?",name,(unsigned int)A,(unsigned int)V); if(GetYN(0)) { if(FCEUI_AddCheat(name,A,V,-1,0)) @@ -326,9 +326,9 @@ static int clistcallb(char *name, uint32 a, uint8 v, int compare, int s, int typ int ret; if(compare>=0) - sprintf(tmp,"%s $%04x:%03d:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,compare,name); + sprintf(tmp,"%s $%04x:%03u:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,compare,name); else - sprintf(tmp,"%s $%04x:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,name); + sprintf(tmp,"%s $%04x:%03u - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,name); if(type==1) tmp[2]='S'; ret=AddToList(tmp,lid); @@ -373,7 +373,7 @@ static void ResetSearch(void) static int srescallb(uint32 a, uint8 last, uint8 current, void *data) { char tmp[14]; - sprintf(tmp, "$%04x:%03d:%03d",(unsigned int)a,(unsigned int)last,(unsigned int)current); + sprintf(tmp, "$%04x:%03u:%03u",(unsigned int)a,(unsigned int)last,(unsigned int)current); return(AddToList(tmp,a)); } diff --git a/src/drivers/common/vidblit.cpp b/src/drivers/common/vidblit.cpp index d93c520a..53f907b5 100644 --- a/src/drivers/common/vidblit.cpp +++ b/src/drivers/common/vidblit.cpp @@ -88,13 +88,13 @@ static int PAL_LUT(uint32 *buffer, int index, int x, int y) static void CalculateShift(uint32 *CBM, int *cshiftr, int *cshiftl) { - int a,x,z,y; + int a,x,z; cshiftl[0]=cshiftl[1]=cshiftl[2]=-1; for(a=0;a<3;a++) { - for(x=0,y=-1,z=0;x<32;x++) + for(x=0,z=0;x<32;x++) { - if(CBM[a]&(1< LogoInfo::height+20) - fprintf(stderr, "'%s': ERROR, expected %dx%d, got %dx%d\n", fn, + fprintf(stderr, "'%s': ERROR, expected %ux%u, got %ux%u\n", fn, LogoInfo::width, LogoInfo::height, new_width, new_height); } @@ -857,7 +857,7 @@ extern "C" std::string avdir = "/home/you/yourlogo/"; char AvName[512]; - sprintf(AvName, "logo_%d_%d_f%03u.png", + sprintf(AvName, "logo_%u_%u_f%03u.png", LogoInfo::width, LogoInfo::height, frameno); diff --git a/src/drivers/win/monitor.cpp b/src/drivers/win/monitor.cpp index d70c13a4..770511dd 100644 --- a/src/drivers/win/monitor.cpp +++ b/src/drivers/win/monitor.cpp @@ -108,7 +108,7 @@ BOOL updateResults(HWND hwndDlg, int rule) int chosen_rules[NUMBER_OF_RULES] = { 0 }; unsigned int values[NUMBER_OF_RULES] = { 0 }; - for (int i=0;icomment) free(sep->comment); + free(sep); } if (msg.comment) free(msg.comment); diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 9ca846c7..27fbb095 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -1305,7 +1305,7 @@ void DumpSubtitles(HWND hWnd) for (unsigned int i = 0; i < subtitleFrames.size(); i++) { - fprintf(srtfile, "%i\n", i+1); // starts with 1, not 0 + fprintf(srtfile, "%u\n", i+1); // starts with 1, not 0 double seconds, ms, endseconds, endms; seconds = subtitleFrames[i]/fps; if (i+1 < subtitleFrames.size()) // there's another subtitle coming after this one @@ -1329,8 +1329,8 @@ void DumpSubtitles(HWND hWnd) floor(endseconds/3600), (int)floor(endseconds/60) % 60, (int)floor(endseconds) % 60, (int)(endms*1000)); fprintf(srtfile, "%s\n\n", subtitleMessages[i].c_str()); // new line for every subtitle } + fclose(srtfile); } - fclose(srtfile); } return; @@ -3526,4 +3526,4 @@ inline bool IsLetterLegalDecHexMixed(char letter) inline bool IsLetterLegalUnsignedDecHexMixed(char letter) { return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$'; -} \ No newline at end of file +}