mirror of https://github.com/snes9xgit/snes9x.git
Fix some possible problems from cppcheck. Everything else looks fine.
This commit is contained in:
parent
f388facb31
commit
026f9eaa1e
|
@ -746,7 +746,6 @@ void S9xAPULoadBlarggState(uint8 *oldblock)
|
|||
spc::reference_time = SNES::get_le32(ptr);
|
||||
ptr += sizeof(int32);
|
||||
spc::remainder = SNES::get_le32(ptr);
|
||||
ptr += sizeof(int32);
|
||||
|
||||
// blargg stores CPUIx in regs_in
|
||||
memcpy (SNES::cpu.registers, regs_in + 4, 4);
|
||||
|
@ -766,8 +765,12 @@ bool8 S9xSPCDump (const char *filename)
|
|||
|
||||
SNES::smp.save_spc (buf);
|
||||
|
||||
if ((ignore = fwrite(buf, SPC_FILE_SIZE, 1, fs)) <= 0)
|
||||
ignore = fwrite (buf, SPC_FILE_SIZE, 1, fs);
|
||||
|
||||
if (ignore == 0)
|
||||
{
|
||||
fprintf (stderr, "Couldn't write file %s.\n", filename);
|
||||
}
|
||||
|
||||
fclose(fs);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Resampler : public ring_buffer
|
|||
virtual void time_ratio (double) = 0;
|
||||
virtual void read (short *, int) = 0;
|
||||
virtual int avail (void) = 0;
|
||||
|
||||
|
||||
Resampler (int num_samples) : ring_buffer (num_samples << 1)
|
||||
{
|
||||
}
|
||||
|
@ -33,19 +33,19 @@ class Resampler : public ring_buffer
|
|||
}
|
||||
|
||||
inline int
|
||||
space_empty (void)
|
||||
space_empty (void) const
|
||||
{
|
||||
return buffer_size - size;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
space_filled (void)
|
||||
space_filled (void) const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
max_write (void)
|
||||
max_write (void) const
|
||||
{
|
||||
return space_empty () >> 1;
|
||||
}
|
||||
|
|
|
@ -69,13 +69,13 @@ public:
|
|||
}
|
||||
|
||||
inline int
|
||||
space_empty (void)
|
||||
space_empty (void) const
|
||||
{
|
||||
return buffer_size - size;
|
||||
}
|
||||
|
||||
inline int
|
||||
space_filled (void)
|
||||
space_filled (void) const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
buffer = new unsigned char[buffer_size];
|
||||
memset (buffer, 0, this->buffer_size);
|
||||
|
||||
size = 0;
|
||||
this->size = 0;
|
||||
start = 0;
|
||||
}
|
||||
|
||||
|
|
6
bsx.cpp
6
bsx.cpp
|
@ -358,12 +358,10 @@ static void BSX_Map_MMC (void)
|
|||
|
||||
static void BSX_Map_FlashIO (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (BSX.MMC[0x0C] || BSX.MMC[0x0D])
|
||||
{
|
||||
// Bank C0:0000, 2AAA, 5555, FF00-FF1F
|
||||
for (c = 0; c < 16; c++)
|
||||
for (int c = 0; c < 16; c++)
|
||||
{
|
||||
Map[c + 0xC00] = (uint8 *) MAP_BSX;
|
||||
BlockIsRAM[c + 0xC00] = TRUE;
|
||||
|
@ -833,7 +831,7 @@ uint8 S9xGetBSXPPU (uint16 address)
|
|||
|
||||
// Data register? (r/w)
|
||||
case 0x2192:
|
||||
t = BSX.PPU[0x2192 - BSXPPUBASE];
|
||||
// t = BSX.PPU[0x2192 - BSXPPUBASE];
|
||||
|
||||
// test
|
||||
t = BSX.test2192[BSX.out_index++];
|
||||
|
|
1
c4.cpp
1
c4.cpp
|
@ -295,7 +295,6 @@ void C4Op1F (void)
|
|||
{
|
||||
tanval = (double) C41FYVal / C41FXVal;
|
||||
C41FAngleRes = (int16) (atan(tanval) / (C4_PI * 2) * 512);
|
||||
C41FAngleRes = C41FAngleRes;
|
||||
if (C41FXVal< 0)
|
||||
C41FAngleRes += 0x100;
|
||||
C41FAngleRes &= 0x1FF;
|
||||
|
|
|
@ -392,7 +392,7 @@ bool ConfigFile::SaveTo(const char *filename){
|
|||
|
||||
if(ferror(fp))
|
||||
{
|
||||
fp = fp;
|
||||
printf ("Error writing config file %s\n", filename);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
|
|
@ -2051,7 +2051,6 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
|
|||
{
|
||||
uint16 r, s, t, st;
|
||||
|
||||
s = t = st = 0;
|
||||
r = cmd.button.joypad.buttons;
|
||||
st = r & joypad[cmd.button.joypad.idx].togglestick & joypad[cmd.button.joypad.idx].toggleturbo;
|
||||
r ^= st;
|
||||
|
@ -2123,7 +2122,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
|
|||
|
||||
if (data1)
|
||||
mouse[cmd.button.mouse.idx].buttons |= i;
|
||||
else
|
||||
else
|
||||
mouse[cmd.button.mouse.idx].buttons &= ~i;
|
||||
|
||||
return;
|
||||
|
|
2
dsp3.cpp
2
dsp3.cpp
|
@ -1140,7 +1140,7 @@ static void DSP3_OP10 (void)
|
|||
DSP3_Reset();
|
||||
else
|
||||
// absorb 2 bytes
|
||||
DSP3.DR = DSP3.DR;
|
||||
DSP3.DR = DSP3.DR; // FIXME?
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -893,7 +893,7 @@ static void fx_plot_2bit (void)
|
|||
#endif
|
||||
|
||||
if (GSU.vPlotOptionReg & 0x02)
|
||||
c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
|
||||
c = ((x ^ y) & 1) ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
|
||||
else
|
||||
c = (uint8) GSU.vColorReg;
|
||||
|
||||
|
@ -957,7 +957,7 @@ static void fx_plot_4bit (void)
|
|||
#endif
|
||||
|
||||
if (GSU.vPlotOptionReg & 0x02)
|
||||
c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
|
||||
c = ((x ^ y) & 1) ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
|
||||
else
|
||||
c = (uint8) GSU.vColorReg;
|
||||
|
||||
|
@ -1172,7 +1172,7 @@ static void fx_cmode (void)
|
|||
{
|
||||
GSU.vPlotOptionReg = SREG;
|
||||
|
||||
if (GSU.vPlotOptionReg & 0x10)
|
||||
if (GSU.vPlotOptionReg & 0x10)
|
||||
GSU.vScreenHeight = 256; // OBJ Mode (for drawing into sprites)
|
||||
else
|
||||
GSU.vScreenHeight = GSU.vScreenRealHeight;
|
||||
|
|
3
getset.h
3
getset.h
|
@ -873,8 +873,7 @@ inline void S9xSetPCBase (uint32 Address)
|
|||
Registers.PBPC = Address & 0xffffff;
|
||||
ICPU.ShiftedPB = Address & 0xff0000;
|
||||
|
||||
int block;
|
||||
uint8 *GetAddress = Memory.Map[block = ((Address & 0xffffff) >> MEMMAP_SHIFT)];
|
||||
uint8 *GetAddress = Memory.Map[(int)((Address & 0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
CPU.MemSpeed = memory_speed(Address);
|
||||
CPU.MemSpeedx2 = CPU.MemSpeed << 1;
|
||||
|
|
|
@ -7,7 +7,7 @@ if test -z "$CXXFLAGS"; then
|
|||
CXXFLAGS="$CFLAGS"
|
||||
fi
|
||||
|
||||
EXTRA_FLAGS="-Wall -W -pedantic -Wno-unused-parameter"
|
||||
EXTRA_FLAGS="-Wall -W -pedantic -Wno-unused-parameter -Wno-unused-but-set-variable"
|
||||
CFLAGS="$CFLAGS $EXTRA_FLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $EXTRA_FLAGS"
|
||||
|
||||
|
|
|
@ -154,9 +154,9 @@ Binding::get_axis (void)
|
|||
GdkModifierType
|
||||
Binding::get_gdk_modifiers (void)
|
||||
{
|
||||
return (GdkModifierType) ((BINDING_CTRL & value ? GDK_CONTROL_MASK : 0) |
|
||||
(BINDING_ALT & value ? GDK_MOD1_MASK : 0) |
|
||||
(BINDING_SHIFT & value ? GDK_SHIFT_MASK : 0));
|
||||
return (GdkModifierType) (((BINDING_CTRL & value) ? GDK_CONTROL_MASK : 0) |
|
||||
((BINDING_ALT & value) ? GDK_MOD1_MASK : 0) |
|
||||
((BINDING_SHIFT & value) ? GDK_SHIFT_MASK : 0));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -192,9 +192,10 @@ Binding::to_string (char *str)
|
|||
|
||||
else
|
||||
{
|
||||
memset (buf, 0, 256);
|
||||
strncpy (buf,
|
||||
keyval_name,
|
||||
256);
|
||||
255);
|
||||
}
|
||||
|
||||
while ((c = strstr (buf, "_")))
|
||||
|
@ -203,9 +204,9 @@ Binding::to_string (char *str)
|
|||
}
|
||||
|
||||
sprintf (str, _("Keyboard %s%s%s%s"),
|
||||
value & BINDING_SHIFT ? "Shift+" : "",
|
||||
value & BINDING_CTRL ? "Ctrl+" : "",
|
||||
value & BINDING_ALT ? "Alt+" : "",
|
||||
(value & BINDING_SHIFT) ? "Shift+" : "",
|
||||
(value & BINDING_CTRL) ? "Ctrl+" : "",
|
||||
(value & BINDING_ALT) ? "Alt+" : "",
|
||||
buf);
|
||||
}
|
||||
|
||||
|
@ -213,14 +214,14 @@ Binding::to_string (char *str)
|
|||
{
|
||||
if ((get_key ()) >= 512)
|
||||
sprintf (buf,
|
||||
_("Axis #%d %s %d%%"),
|
||||
_("Axis #%u %s %u%%"),
|
||||
get_axis (),
|
||||
is_positive () ? "+" : "-",
|
||||
get_threshold ());
|
||||
else
|
||||
sprintf (buf, _("Button %d"), get_key ());
|
||||
sprintf (buf, _("Button %u"), get_key ());
|
||||
|
||||
sprintf (str, _("Joystick %d %s"), get_device (), buf);
|
||||
sprintf (str, _("Joystick %u %s"), get_device (), buf);
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -314,7 +314,7 @@ S9xXVDisplayDriver::init (void)
|
|||
{
|
||||
if (!strcmp (port_attr[i].name, "XV_AUTOPAINT_COLORKEY"))
|
||||
{
|
||||
Atom colorkey = None;
|
||||
Atom colorkey;
|
||||
|
||||
colorkey = XInternAtom (display, "XV_AUTOPAINT_COLORKEY", True);
|
||||
if (colorkey != None)
|
||||
|
|
|
@ -71,10 +71,12 @@ S9xAlsaSoundDriver::open_device (void)
|
|||
printf ("ALSA sound driver initializing...\n");
|
||||
printf (" --> (Device: default)...");
|
||||
|
||||
if ((err = snd_pcm_open (&pcm,
|
||||
"default",
|
||||
SND_PCM_STREAM_PLAYBACK,
|
||||
SND_PCM_NONBLOCK) < 0))
|
||||
err = snd_pcm_open (&pcm,
|
||||
"default",
|
||||
SND_PCM_STREAM_PLAYBACK,
|
||||
SND_PCM_NONBLOCK);
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
@ -9,33 +9,33 @@ main (int argc,
|
|||
unsigned char inchar;
|
||||
unsigned int counter;
|
||||
struct stat file_info;
|
||||
|
||||
if (argc != 4)
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s infile outfile identifier\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
stat (argv[1], &file_info);
|
||||
|
||||
|
||||
infile = fopen (argv[1], "r");
|
||||
|
||||
|
||||
if (!infile)
|
||||
{
|
||||
fprintf (stderr, "Input file doesn't exist.\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
outfile = fopen (argv[2], "w+");
|
||||
|
||||
fprintf (outfile,
|
||||
"int %s_size = %d;\n\n",
|
||||
argv[3],
|
||||
|
||||
fprintf (outfile,
|
||||
"int %s_size = %d;\n\n",
|
||||
argv[3],
|
||||
(int) file_info.st_size);
|
||||
fprintf (outfile, "unsigned char %s [] = \n{\n ", argv[3]);
|
||||
|
||||
|
||||
counter = 0;
|
||||
|
||||
|
||||
while (fread (&inchar, 1, 1, infile))
|
||||
{
|
||||
if (counter >= 32)
|
||||
|
@ -43,15 +43,18 @@ main (int argc,
|
|||
counter = 0;
|
||||
fprintf (outfile, "\n ");
|
||||
}
|
||||
|
||||
|
||||
fprintf (outfile, "%d,", inchar);
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
/* Erase extra "," */
|
||||
fseek (outfile, -1, SEEK_CUR);
|
||||
|
||||
|
||||
fprintf (outfile, "\n};\n");
|
||||
|
||||
|
||||
fclose (infile);
|
||||
fclose (outfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -822,7 +822,10 @@ int S9xMovieOpen (const char *filename, bool8 read_only)
|
|||
}
|
||||
|
||||
if (fseek(fd, Movie.ControllerDataOffset, SEEK_SET))
|
||||
{
|
||||
fclose(fd);
|
||||
return (WRONG_FORMAT);
|
||||
}
|
||||
|
||||
Movie.File = fd;
|
||||
Movie.BytesPerSample = bytes_per_sample();
|
||||
|
@ -970,7 +973,10 @@ int S9xMovieGetInfo (const char *filename, struct MovieInfo *info)
|
|||
|
||||
result = read_movie_header(fd, &local_movie);
|
||||
if (result != SUCCESS)
|
||||
{
|
||||
fclose(fd);
|
||||
return (result);
|
||||
}
|
||||
|
||||
info->TimeCreated = (time_t) local_movie.MovieId;
|
||||
info->Version = local_movie.Version;
|
||||
|
|
22
netplay.cpp
22
netplay.cpp
|
@ -386,10 +386,10 @@ on the remote machine on this port?");
|
|||
{
|
||||
S9xNPSetError ("Sending 'HELLO' message failed.");
|
||||
S9xNPDisconnect ();
|
||||
delete tmp;
|
||||
delete[] tmp;
|
||||
return (FALSE);
|
||||
}
|
||||
delete tmp;
|
||||
delete[] tmp;
|
||||
|
||||
#ifdef NP_DEBUG
|
||||
printf ("CLIENT: Waiting for 'WELCOME' reply from server @%ld...\n", S9xGetMilliTime () - START);
|
||||
|
@ -420,7 +420,7 @@ on the remote machine on this port?");
|
|||
if (!S9xNPGetData (NetPlay.Socket, data, len - 7))
|
||||
{
|
||||
S9xNPSetError ("Error in 'HELLO' reply packet received from server.");
|
||||
delete data;
|
||||
delete[] data;
|
||||
S9xNPDisconnect ();
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ on the remote machine on this port?");
|
|||
S9xNPSetError ("\
|
||||
The Snes9X NetPlay server implements a different\n\
|
||||
version of the protocol. Disconnecting.");
|
||||
delete data;
|
||||
delete[] data;
|
||||
S9xNPDisconnect ();
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -442,13 +442,13 @@ version of the protocol. Disconnecting.");
|
|||
{
|
||||
if (!S9xNPLoadROMDialog ((char *) data + 4 + 2))
|
||||
{
|
||||
delete data;
|
||||
delete[] data;
|
||||
S9xNPDisconnect ();
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
NetPlay.Player = data [1];
|
||||
delete data;
|
||||
delete[] data;
|
||||
|
||||
NetPlay.PendingWait4Sync = TRUE;
|
||||
Settings.NetPlay = TRUE;
|
||||
|
@ -754,7 +754,7 @@ bool8 S9xNPLoadROM (uint32 len)
|
|||
if (!S9xNPGetData (NetPlay.Socket, data, len))
|
||||
{
|
||||
S9xNPSetError ("Error while receiving ROM name.");
|
||||
delete data;
|
||||
delete[] data;
|
||||
S9xNPDisconnect ();
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -763,11 +763,11 @@ bool8 S9xNPLoadROM (uint32 len)
|
|||
if (!S9xNPLoadROMDialog ((char *) data))
|
||||
{
|
||||
S9xNPSetError ("Disconnected from NetPlay server because you are playing a different game!");
|
||||
delete data;
|
||||
delete[] data;
|
||||
S9xNPDisconnect ();
|
||||
return (FALSE);
|
||||
}
|
||||
delete data;
|
||||
delete[] data;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
@ -878,7 +878,7 @@ void S9xNPGetFreezeFile (uint32 len)
|
|||
{
|
||||
S9xNPSetError ("Error while receiving freeze file from server.");
|
||||
S9xNPDisconnect ();
|
||||
delete data;
|
||||
delete[] data;
|
||||
return;
|
||||
}
|
||||
S9xNPSetAction ("", TRUE);
|
||||
|
@ -924,7 +924,7 @@ void S9xNPGetFreezeFile (uint32 len)
|
|||
remove (fname);
|
||||
} else
|
||||
S9xNPSetError ("Unable to get name for temporary freeze file.");
|
||||
delete data;
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
uint32 S9xNPGetJoypad (int which1)
|
||||
|
|
|
@ -535,7 +535,7 @@ void S9xNPProcessClient (int c)
|
|||
|
||||
len = 7 + 1 + 1 + 4 + strlen (NPServer.ROMName) + 1;
|
||||
|
||||
delete data;
|
||||
delete[] data;
|
||||
ptr = data = new uint8 [len];
|
||||
*ptr++ = NP_SERV_MAGIC;
|
||||
*ptr++ = NPServer.Clients [c].SendSequenceNum++;
|
||||
|
@ -563,7 +563,7 @@ void S9xNPProcessClient (int c)
|
|||
S9xNPShutdownClient (c, TRUE);
|
||||
return;
|
||||
}
|
||||
delete data;
|
||||
delete[] data;
|
||||
#ifdef NP_DEBUG
|
||||
printf ("SERVER: Waiting for a response from the client @%ld...\n", S9xGetMilliTime () - START);
|
||||
#endif
|
||||
|
@ -1306,7 +1306,7 @@ void S9xNPSendROMLoadRequest (const char *filename)
|
|||
}
|
||||
}
|
||||
}
|
||||
delete data;
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void S9xNPSendSRAMToAllClients ()
|
||||
|
|
|
@ -701,7 +701,7 @@ static bool8 SetupXvideo()
|
|||
{
|
||||
if (!strcmp (port_attr[i].name, "XV_AUTOPAINT_COLORKEY"))
|
||||
{
|
||||
Atom colorkey = None;
|
||||
Atom colorkey;
|
||||
|
||||
colorkey = XInternAtom (GUI.display, "XV_AUTOPAINT_COLORKEY", True);
|
||||
if (colorkey != None)
|
||||
|
|
Loading…
Reference in New Issue