Merge pull request #164 from mjbudd77/master

Cleaned up a few compiler and cppcheck warnings in code base. There a…
This commit is contained in:
mjbudd77 2020-08-14 23:11:16 -04:00 committed by GitHub
commit 5752310804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 28 deletions

View File

@ -604,8 +604,8 @@ void OPLL_reset(OPLL * opll) {
for (i = 0; i < 0x40; i++) for (i = 0; i < 0x40; i++)
OPLL_writeReg(opll, i, 0); OPLL_writeReg(opll, i, 0);
opll->realstep = (uint32)((1 << 31) / rate); opll->realstep = (uint32)((1u << 31) / rate);
opll->opllstep = (uint32)((1 << 31) / (clk / 72)); opll->opllstep = (uint32)((1u << 31) / (clk / 72));
opll->oplltime = 0; opll->oplltime = 0;
} }

View File

@ -82,10 +82,10 @@ static int prg_mask;
//PRG wrapper //PRG wrapper
static void BMCFK23CPW(uint32 A, uint8 V) static void BMCFK23CPW(uint32 A, uint8 V)
{ {
uint32 bank = (EXPREGS[1] & 0x1F); //uint32 bank = (EXPREGS[1] & 0x1F);
uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0); //uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0);
uint32 block = (EXPREGS[1] & 0x60) | hiblock; //uint32 block = (EXPREGS[1] & 0x60) | hiblock;
uint32 extra = (EXPREGS[3] & 2); //uint32 extra = (EXPREGS[3] & 2);
// FCEU_printf("0:%04X:%02X\n",A,V); // FCEU_printf("0:%04X:%02X\n",A,V);
if((EXPREGS[0]&7)==4) if((EXPREGS[0]&7)==4)
@ -161,7 +161,7 @@ static DECLFW(BMCFK23CWrite)
EXPREGS[A&3]=V; EXPREGS[A&3]=V;
// BUT WHY is there any rom that need it actually? // 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("K3:(exp0=%02x)\n",EXPREGS[0]);
// FCEU_printf("WH0:%04X:%02X\n",A,V); // 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 //this little hack makes sure that we try all the dip switch settings eventually, if we reset enough
dipswitch++; dipswitch++;
dipswitch&=7; 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[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF; EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;

View File

@ -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 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); if(strlen(str)!=8) return(0);
sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3); sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3);
@ -932,4 +932,4 @@ inline void FCEUI_ReleaseCheatMap()
free(cheatMap); free(cheatMap);
cheatMap = NULL; cheatMap = NULL;
} }
} }

View File

@ -194,10 +194,10 @@ Condition* Parentheses(const char** str, Condition* c, char openPar, char closeP
{ {
scan(str); scan(str);
c->lhs = Connect(str);
if (!c) return 0; if (!c) return 0;
c->lhs = Connect(str);
if (next == closePar) if (next == closePar)
{ {
scan(str); scan(str);

View File

@ -22,7 +22,7 @@ int offsetStringToInt(unsigned int type, const char* offsetBuffer)
{ {
int offset = -1; int offset = -1;
if (sscanf(offsetBuffer,"%4X",&offset) == EOF) if (sscanf(offsetBuffer,"%4X",(unsigned int *)&offset) == EOF)
{ {
return -1; return -1;
} }

View File

@ -226,7 +226,7 @@ static void ModifyCheat(int num)
printf("Address [$%04x]: ",(unsigned int)A); printf("Address [$%04x]: ",(unsigned int)A);
A=GetH16(A); A=GetH16(A);
printf("Value [%03d]: ",(unsigned int)V); printf("Value [%03u]: ",(unsigned int)V);
V=Get8(V); V=Get8(V);
printf("Compare [%3d]: ",compare); printf("Compare [%3d]: ",compare);
@ -302,9 +302,9 @@ static void AddCheatParam(uint32 A, uint8 V)
GetString(name,256); GetString(name,256);
printf("Address [$%04x]: ",(unsigned int)A); printf("Address [$%04x]: ",(unsigned int)A);
A=GetH16(A); A=GetH16(A);
printf("Value [%03d]: ",(unsigned int)V); printf("Value [%03u]: ",(unsigned int)V);
V=Get8(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(GetYN(0))
{ {
if(FCEUI_AddCheat(name,A,V,-1,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; int ret;
if(compare>=0) 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 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) if(type==1)
tmp[2]='S'; tmp[2]='S';
ret=AddToList(tmp,lid); ret=AddToList(tmp,lid);
@ -373,7 +373,7 @@ static void ResetSearch(void)
static int srescallb(uint32 a, uint8 last, uint8 current, void *data) static int srescallb(uint32 a, uint8 last, uint8 current, void *data)
{ {
char tmp[14]; 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)); return(AddToList(tmp,a));
} }

View File

@ -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) 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; cshiftl[0]=cshiftl[1]=cshiftl[2]=-1;
for(a=0;a<3;a++) 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<<x)) if(CBM[a]&(1u<<x))
{ {
if(cshiftl[a]==-1) cshiftl[a]=x; if(cshiftl[a]==-1) cshiftl[a]=x;
z++; z++;

View File

@ -828,7 +828,7 @@ extern "C"
|| new_height != LogoInfo::height) || new_height != LogoInfo::height)
{ {
if(new_height < LogoInfo::height || new_height > LogoInfo::height+20) if(new_height < LogoInfo::height || new_height > 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, LogoInfo::width, LogoInfo::height,
new_width, new_height); new_width, new_height);
} }
@ -857,7 +857,7 @@ extern "C"
std::string avdir = "/home/you/yourlogo/"; std::string avdir = "/home/you/yourlogo/";
char AvName[512]; char AvName[512];
sprintf(AvName, "logo_%d_%d_f%03u.png", sprintf(AvName, "logo_%u_%u_f%03u.png",
LogoInfo::width, LogoInfo::width,
LogoInfo::height, LogoInfo::height,
frameno); frameno);

View File

@ -108,7 +108,7 @@ BOOL updateResults(HWND hwndDlg, int rule)
int chosen_rules[NUMBER_OF_RULES] = { 0 }; int chosen_rules[NUMBER_OF_RULES] = { 0 };
unsigned int values[NUMBER_OF_RULES] = { 0 }; unsigned int values[NUMBER_OF_RULES] = { 0 };
for (int i=0;i<sizeof(chosen_rules) && i <= rule;i++) for (int i=0;i<NUMBER_OF_RULES && i <= rule;i++)
{ {
chosen_rules[i] = SendDlgItemMessage(hwndDlg, RULE_BOX_1 + i, CB_GETCURSEL, 0, 0); chosen_rules[i] = SendDlgItemMessage(hwndDlg, RULE_BOX_1 + i, CB_GETCURSEL, 0, 0);

View File

@ -1419,6 +1419,7 @@ INT_PTR CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
if (target[i].comment) if (target[i].comment)
free(target[i].comment); free(target[i].comment);
} }
free(target);
} }
if(msg.Addresses) if(msg.Addresses)
free(msg.Addresses); free(msg.Addresses);
@ -1442,6 +1443,7 @@ INT_PTR CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
InsertWatch(*sep); InsertWatch(*sep);
if (sep->comment) if (sep->comment)
free(sep->comment); free(sep->comment);
free(sep);
} }
if (msg.comment) if (msg.comment)
free(msg.comment); free(msg.comment);

View File

@ -1305,7 +1305,7 @@ void DumpSubtitles(HWND hWnd)
for (unsigned int i = 0; i < subtitleFrames.size(); i++) 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; double seconds, ms, endseconds, endms;
seconds = subtitleFrames[i]/fps; seconds = subtitleFrames[i]/fps;
if (i+1 < subtitleFrames.size()) // there's another subtitle coming after this one 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)); 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 fprintf(srtfile, "%s\n\n", subtitleMessages[i].c_str()); // new line for every subtitle
} }
fclose(srtfile);
} }
fclose(srtfile);
} }
return; return;
@ -3526,4 +3526,4 @@ inline bool IsLetterLegalDecHexMixed(char letter)
inline bool IsLetterLegalUnsignedDecHexMixed(char letter) inline bool IsLetterLegalUnsignedDecHexMixed(char letter)
{ {
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$'; return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
} }