Fix a bunch of warnings.

This commit is contained in:
Brandon Wright 2018-05-13 20:17:02 -05:00
parent 20127f4473
commit a42498b161
14 changed files with 46 additions and 75 deletions

View File

@ -2346,7 +2346,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
if (S9xUnfreezeGame(filename)) if (S9xUnfreezeGame(filename))
{ {
sprintf(buf, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops"); snprintf(buf, 256, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
S9xSetInfoString (buf); S9xSetInfoString (buf);
} }
else else
@ -2383,7 +2383,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
if (S9xUnfreezeGame(filename)) if (S9xUnfreezeGame(filename))
{ {
sprintf(buf, "%s.%03d loaded", def, i - QuickLoad000); snprintf(buf, 256, "%s.%03d loaded", def, i - QuickLoad000);
S9xSetInfoString(buf); S9xSetInfoString(buf);
} }
else else
@ -2410,7 +2410,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
_splitpath(Memory.ROMFilename, drive, dir, def, ext); _splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickSave000); snprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickSave000);
sprintf(buf, "%s.%03d saved", def, i - QuickSave000); snprintf(buf, 256, "%s.%03d saved", def, i - QuickSave000);
S9xSetInfoString(buf); S9xSetInfoString(buf);
S9xFreezeGame(filename); S9xFreezeGame(filename);

View File

@ -896,9 +896,9 @@ static void DSP1_Project (int16 X, int16 Y, int16 Z, int16 *H, int16 *V, int16 *
Py = DSP1_ShiftR(Py, E - refE); Py = DSP1_ShiftR(Py, E - refE);
Pz = DSP1_ShiftR(Pz, E3 - refE); Pz = DSP1_ShiftR(Pz, E3 - refE);
C11 =- (Px * DSP1.Nx >> 15); C11 = -(Px * DSP1.Nx >> 15);
C8 =- (Py * DSP1.Ny >> 15); C8 = -(Py * DSP1.Ny >> 15);
C9 =- (Pz * DSP1.Nz >> 15); C9 = -(Pz * DSP1.Nz >> 15);
C12 = C11 + C8 + C9; // this cannot overflow! C12 = C11 + C8 + C9; // this cannot overflow!
aux4 = C12; // de-normalization with 32-bits arithmetic aux4 = C12; // de-normalization with 32-bits arithmetic

View File

@ -293,13 +293,11 @@ void SuperEagle (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes,
for (int i = 0; i < width; i++) for (int i = 0; i < width; i++)
{ {
uint32 color1, color2, color3, color4, color5, color6; uint32 color1, color2, color3, color4, color5, color6;
uint32 colorA0, colorA1, colorA2, colorA3, colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; uint32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
uint32 product1a, product1b, product2a, product2b; uint32 product1a, product1b, product2a, product2b;
colorB0 = *(bP - nextline - 1);
colorB1 = *(bP - nextline ); colorB1 = *(bP - nextline );
colorB2 = *(bP - nextline + 1); colorB2 = *(bP - nextline + 1);
colorB3 = *(bP - nextline + 2);
color4 = *(bP - 1); color4 = *(bP - 1);
color5 = *(bP ); color5 = *(bP );
@ -311,10 +309,8 @@ void SuperEagle (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes,
color3 = *(bP + nextline + 1); color3 = *(bP + nextline + 1);
colorS1 = *(bP + nextline + 2); colorS1 = *(bP + nextline + 2);
colorA0 = *(bP + nextline + nextline - 1);
colorA1 = *(bP + nextline + nextline ); colorA1 = *(bP + nextline + nextline );
colorA2 = *(bP + nextline + nextline + 1); colorA2 = *(bP + nextline + nextline + 1);
colorA3 = *(bP + nextline + nextline + 2);
if (color2 == color6 && color5 != color3) if (color2 == color6 && color5 != color3)
{ {

View File

@ -1511,7 +1511,6 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff)
int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1; int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1;
bool8 HiresInterlace = IPPU.Interlace && IPPU.DoubleWidthPixels; bool8 HiresInterlace = IPPU.Interlace && IPPU.DoubleWidthPixels;
void (*DrawTile) (uint32, uint32, uint32, uint32);
void (*DrawClippedTile) (uint32, uint32, uint32, uint32, uint32, uint32); void (*DrawClippedTile) (uint32, uint32, uint32, uint32, uint32, uint32);
for (int clip = 0; clip < GFX.Clip[bg].Count; clip++) for (int clip = 0; clip < GFX.Clip[bg].Count; clip++)
@ -1520,12 +1519,10 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff)
if (BG.EnableMath && (GFX.Clip[bg].DrawMode[clip] & 2)) if (BG.EnableMath && (GFX.Clip[bg].DrawMode[clip] & 2))
{ {
DrawTile = GFX.DrawTileMath;
DrawClippedTile = GFX.DrawClippedTileMath; DrawClippedTile = GFX.DrawClippedTileMath;
} }
else else
{ {
DrawTile = GFX.DrawTileNomath;
DrawClippedTile = GFX.DrawClippedTileNomath; DrawClippedTile = GFX.DrawClippedTileNomath;
} }

View File

@ -9,7 +9,7 @@ if test -z "$CXXFLAGS"; then
CXXFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS"
fi fi
EXTRA_FLAGS="-Wall -W -pedantic -Wno-unused-parameter" EXTRA_FLAGS="-Wall -W -Wno-unused-parameter"
CFLAGS="$CFLAGS $EXTRA_FLAGS" CFLAGS="$CFLAGS $EXTRA_FLAGS"
CXXFLAGS="$CXXFLAGS $EXTRA_FLAGS" CXXFLAGS="$CXXFLAGS $EXTRA_FLAGS"

View File

@ -172,15 +172,9 @@ swap_controllers_1_2 (void)
{ {
JoypadBinding interrim; JoypadBinding interrim;
memcpy (&interrim, interrim = gui_config->pad[0];
&gui_config->pad[0], gui_config->pad[0] = gui_config->pad[1];
sizeof (JoypadBinding)); gui_config->pad[1] = interrim;
memcpy (&gui_config->pad[0],
&gui_config->pad[1],
sizeof (JoypadBinding));
memcpy (&gui_config->pad[1],
&interrim,
sizeof (JoypadBinding));
gui_config->rebind_keys (); gui_config->rebind_keys ();

View File

@ -36,7 +36,6 @@ class S9xXVDisplayDriver : public S9xDisplayDriver
Display *display; Display *display;
Window xwindow; Window xwindow;
GC xgc;
Colormap xcolormap; Colormap xcolormap;
XVisualInfo *vi; XVisualInfo *vi;
GdkWindow *gdk_window; GdkWindow *gdk_window;

View File

@ -4,7 +4,7 @@
#include "gtk_s9x.h" #include "gtk_s9x.h"
static char buf[256]; static char buf[PATH_MAX];
const char * const char *
S9xChooseMovieFilename (bool8 read_only) S9xChooseMovieFilename (bool8 read_only)
@ -499,13 +499,13 @@ S9xQuickSaveSlot (int slot)
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (filename, "%s%s%s.%03d", snprintf (filename, PATH_MAX, "%s%s%s.%03d",
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def, S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
slot); slot);
if (S9xFreezeGame (filename)) if (S9xFreezeGame (filename))
{ {
sprintf (buf, "%s.%03d saved", def, slot); snprintf (buf, PATH_MAX, "%s.%03d saved", def, slot);
S9xSetInfoString (buf); S9xSetInfoString (buf);
} }
@ -524,13 +524,13 @@ S9xQuickLoadSlot (int slot)
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (filename, "%s%s%s.%03d", snprintf (filename, PATH_MAX, "%s%s%s.%03d",
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def, S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
slot); slot);
if (S9xUnfreezeGame (filename)) if (S9xUnfreezeGame (filename))
{ {
sprintf (buf, "%s.%03d loaded", def, slot); snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
S9xSetInfoString (buf); S9xSetInfoString (buf);
} }
else else
@ -539,13 +539,13 @@ S9xQuickLoadSlot (int slot)
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (filename, "%s%s%s.zs%c", snprintf (filename, PATH_MAX, "%s%s%s.zs%c",
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
def, digits[slot]); def, digits[slot]);
if (S9xUnfreezeGame (filename)) if (S9xUnfreezeGame (filename))
{ {
sprintf (buf, snprintf (buf, PATH_MAX,
"Loaded ZSNES freeze file %s.zs%c", "Loaded ZSNES freeze file %s.zs%c",
def, digits [slot]); def, digits [slot]);
S9xSetInfoString (buf); S9xSetInfoString (buf);

View File

@ -1263,9 +1263,9 @@ Snes9xPreferences::swap_with (void)
int source_joypad = get_combo ("control_combo"); int source_joypad = get_combo ("control_combo");
int dest_joypad = get_combo ("joypad_to_swap_with"); int dest_joypad = get_combo ("joypad_to_swap_with");
memcpy (&mediator, &pad[source_joypad], sizeof (JoypadBinding)); mediator = pad[source_joypad];
memcpy (&pad[source_joypad], &pad[dest_joypad], sizeof (JoypadBinding)); pad[source_joypad] = pad[dest_joypad];
memcpy (&pad[dest_joypad], &mediator, sizeof (JoypadBinding)); pad[dest_joypad] = mediator;
bindings_to_dialog (source_joypad); bindings_to_dialog (source_joypad);
@ -1277,7 +1277,10 @@ Snes9xPreferences::reset_current_joypad (void)
{ {
int joypad = get_combo ("control_combo"); int joypad = get_combo ("control_combo");
memset (&pad[joypad], 0, sizeof (JoypadBinding)); for (unsigned int i = 0; i < NUM_JOYPAD_LINKS; i++)
{
pad[joypad].data[i].clear();
}
bindings_to_dialog (joypad); bindings_to_dialog (joypad);

View File

@ -850,7 +850,7 @@ Snes9xWindow::open_movie_dialog (bool readonly)
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (default_name, "%s.smv", def); snprintf (default_name, PATH_MAX, "%s.smv", def);
dialog = gtk_file_chooser_dialog_new (_("New SNES Movie"), dialog = gtk_file_chooser_dialog_new (_("New SNES Movie"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
@ -1116,7 +1116,7 @@ Snes9xWindow::save_state_dialog ()
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (default_name, "%s.sst", def); snprintf (default_name, PATH_MAX, "%s.sst", def);
dialog = gtk_file_chooser_dialog_new (_("Save State"), dialog = gtk_file_chooser_dialog_new (_("Save State"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
@ -1194,7 +1194,7 @@ Snes9xWindow::save_spc_dialog ()
_splitpath (Memory.ROMFilename, drive, dir, def, ext); _splitpath (Memory.ROMFilename, drive, dir, def, ext);
sprintf (default_name, "%s.spc", def); snprintf (default_name, PATH_MAX, "%s.spc", def);
dialog = gtk_file_chooser_dialog_new (_("Save SPC file..."), dialog = gtk_file_chooser_dialog_new (_("Save SPC file..."),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),

View File

@ -284,16 +284,7 @@ namespace JMA
stream.read((char *)int4_buffer, UINT_SIZE); stream.read((char *)int4_buffer, UINT_SIZE);
size_t compressed_size = charp_to_uint(int4_buffer); size_t compressed_size = charp_to_uint(int4_buffer);
//Allocate memory of the correct size to hold the compressed data in the JMA compressed_buffer = new unsigned char[compressed_size];
//Throw error on failure as that is unrecoverable from
try
{
compressed_buffer = new unsigned char[compressed_size];
}
catch (bad_alloc xa)
{
throw(JMA_NO_MEM_ALLOC);
}
//Read all the compressed data in //Read all the compressed data in
stream.read((char *)compressed_buffer, compressed_size); stream.read((char *)compressed_buffer, compressed_size);
@ -441,17 +432,11 @@ namespace JMA
//Allocate memory for compressed and decompressed data //Allocate memory for compressed and decompressed data
unsigned char *comp_buffer = 0, *decomp_buffer = 0; unsigned char *comp_buffer = 0, *decomp_buffer = 0;
try
{ //Compressed data size is <= non compressed size
//Compressed data size is <= non compressed size unsigned char *combined_buffer = new unsigned char[chunk_size*2];
unsigned char *combined_buffer = new unsigned char[chunk_size*2]; comp_buffer = combined_buffer;
comp_buffer = combined_buffer; decomp_buffer = combined_buffer+chunk_size;
decomp_buffer = combined_buffer+chunk_size;
}
catch (bad_alloc xa)
{
throw(JMA_NO_MEM_ALLOC);
}
size_t first_chunk_offset = size_to_skip % chunk_size; size_t first_chunk_offset = size_to_skip % chunk_size;
unsigned char int4_buffer[UINT_SIZE]; unsigned char int4_buffer[UINT_SIZE];
@ -492,14 +477,7 @@ namespace JMA
else //Solid JMA else //Solid JMA
{ {
unsigned char *decomp_buffer = 0; unsigned char *decomp_buffer = 0;
try decomp_buffer = new unsigned char[get_total_size(files)];
{
decomp_buffer = new unsigned char[get_total_size(files)];
}
catch (bad_alloc xa)
{
throw(JMA_NO_MEM_ALLOC);
}
get_all_files(decomp_buffer); get_all_files(decomp_buffer);

View File

@ -360,7 +360,6 @@ static bool8 S9xNPSGetData (int socket, uint8 *data, int length)
static bool8 S9xNPSSendData (int fd, const uint8 *data, int length) static bool8 S9xNPSSendData (int fd, const uint8 *data, int length)
{ {
int Percent = 0;
int len = length; int len = length;
int chunk = length / 50; int chunk = length / 50;
@ -404,8 +403,8 @@ static bool8 S9xNPSSendData (int fd, const uint8 *data, int length)
data += sent; data += sent;
if (length > 1024) if (length > 1024)
{ {
Percent = (uint8) (((length - len) * 100) / length);
#ifdef __WIN32__ #ifdef __WIN32__
int Percent = (uint8) (((length - len) * 100) / length);
PostMessage (GUI.hWnd, WM_USER, Percent, Percent); PostMessage (GUI.hWnd, WM_USER, Percent, Percent);
Sleep (0); Sleep (0);
#endif #endif
@ -1057,12 +1056,15 @@ void S9xNPServerLoop (void *)
bool8 S9xNPStartServer (int port) bool8 S9xNPStartServer (int port)
{ {
#ifdef __WIN32__
static int p; static int p;
p = port;
#endif
#ifdef NP_DEBUG #ifdef NP_DEBUG
printf ("SERVER: Starting server on port %d @%ld\n", port, S9xGetMilliTime () - START); printf ("SERVER: Starting server on port %d @%ld\n", port, S9xGetMilliTime () - START);
#endif #endif
p = port;
server_continue = TRUE; server_continue = TRUE;
if (S9xNPServerInit (port)) if (S9xNPServerInit (port))
#ifdef __WIN32__ #ifdef __WIN32__

View File

@ -321,8 +321,9 @@ GLuint GLSLShader::compile_shader(char *program,
glCompileShader (shader); glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status); glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
info_log[0] = '\0';
glGetShaderInfoLog (shader, 1024, NULL, info_log); glGetShaderInfoLog (shader, 1024, NULL, info_log);
if (info_log && *info_log) if (*info_log)
printf ("%s\n", info_log); printf ("%s\n", info_log);
*out = shader; *out = shader;
@ -408,8 +409,9 @@ bool GLSLShader::load_shader (char *filename)
glLinkProgram (p->program); glLinkProgram (p->program);
glGetProgramiv (p->program, GL_LINK_STATUS, &status); glGetProgramiv (p->program, GL_LINK_STATUS, &status);
log[0] = '\0';
glGetProgramInfoLog(p->program, 1024, NULL, log); glGetProgramInfoLog(p->program, 1024, NULL, log);
if (log && *log) if (*log)
printf ("%s\n", log); printf ("%s\n", log);
glDeleteShader (vertex_shader); glDeleteShader (vertex_shader);
@ -833,7 +835,7 @@ void GLSLShader::set_shader_vars (unsigned int p)
if (attr > -1) \ if (attr > -1) \
{ \ { \
glEnableVertexAttribArray(attr); \ glEnableVertexAttribArray(attr); \
glVertexAttribPointer(attr, 2, GL_FLOAT, GL_FALSE, 0, ((float *) NULL) + offset); \ glVertexAttribPointer(attr, 2, GL_FLOAT, GL_FALSE, 0, (void *)(sizeof (float) * offset)); \
vaos.push_back (attr); \ vaos.push_back (attr); \
} }
#define setTexCoordsNoOffset(attr) \ #define setTexCoordsNoOffset(attr) \

View File

@ -1192,7 +1192,7 @@ void S9xResetSaveTimer (bool8 dontsave)
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, def, ext); _splitpath(Memory.ROMFilename, drive, dir, def, ext);
sprintf(filename, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops"); snprintf(filename, PATH_MAX + 1, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops");
S9xMessage(S9X_INFO, S9X_FREEZE_FILE_INFO, SAVE_INFO_OOPS); S9xMessage(S9X_INFO, S9X_FREEZE_FILE_INFO, SAVE_INFO_OOPS);
S9xFreezeGame(filename); S9xFreezeGame(filename);
} }