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))
{
sprintf(buf, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
snprintf(buf, 256, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
S9xSetInfoString (buf);
}
else
@ -2383,7 +2383,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
if (S9xUnfreezeGame(filename))
{
sprintf(buf, "%s.%03d loaded", def, i - QuickLoad000);
snprintf(buf, 256, "%s.%03d loaded", def, i - QuickLoad000);
S9xSetInfoString(buf);
}
else
@ -2410,7 +2410,7 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
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);
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);
Pz = DSP1_ShiftR(Pz, E3 - refE);
C11 =- (Px * DSP1.Nx >> 15);
C8 =- (Py * DSP1.Ny >> 15);
C9 =- (Pz * DSP1.Nz >> 15);
C11 = -(Px * DSP1.Nx >> 15);
C8 = -(Py * DSP1.Ny >> 15);
C9 = -(Pz * DSP1.Nz >> 15);
C12 = C11 + C8 + C9; // this cannot overflow!
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++)
{
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;
colorB0 = *(bP - nextline - 1);
colorB1 = *(bP - nextline );
colorB2 = *(bP - nextline + 1);
colorB3 = *(bP - nextline + 2);
color4 = *(bP - 1);
color5 = *(bP );
@ -311,10 +309,8 @@ void SuperEagle (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes,
color3 = *(bP + nextline + 1);
colorS1 = *(bP + nextline + 2);
colorA0 = *(bP + nextline + nextline - 1);
colorA1 = *(bP + nextline + nextline );
colorA2 = *(bP + nextline + nextline + 1);
colorA3 = *(bP + nextline + nextline + 2);
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;
bool8 HiresInterlace = IPPU.Interlace && IPPU.DoubleWidthPixels;
void (*DrawTile) (uint32, uint32, uint32, uint32);
void (*DrawClippedTile) (uint32, uint32, uint32, uint32, uint32, uint32);
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))
{
DrawTile = GFX.DrawTileMath;
DrawClippedTile = GFX.DrawClippedTileMath;
}
else
{
DrawTile = GFX.DrawTileNomath;
DrawClippedTile = GFX.DrawClippedTileNomath;
}

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
#include "gtk_s9x.h"
static char buf[256];
static char buf[PATH_MAX];
const char *
S9xChooseMovieFilename (bool8 read_only)
@ -499,13 +499,13 @@ S9xQuickSaveSlot (int slot)
_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,
slot);
if (S9xFreezeGame (filename))
{
sprintf (buf, "%s.%03d saved", def, slot);
snprintf (buf, PATH_MAX, "%s.%03d saved", def, slot);
S9xSetInfoString (buf);
}
@ -524,13 +524,13 @@ S9xQuickLoadSlot (int slot)
_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,
slot);
if (S9xUnfreezeGame (filename))
{
sprintf (buf, "%s.%03d loaded", def, slot);
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
S9xSetInfoString (buf);
}
else
@ -539,13 +539,13 @@ S9xQuickLoadSlot (int slot)
_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,
def, digits[slot]);
if (S9xUnfreezeGame (filename))
{
sprintf (buf,
snprintf (buf, PATH_MAX,
"Loaded ZSNES freeze file %s.zs%c",
def, digits [slot]);
S9xSetInfoString (buf);

View File

@ -1263,9 +1263,9 @@ Snes9xPreferences::swap_with (void)
int source_joypad = get_combo ("control_combo");
int dest_joypad = get_combo ("joypad_to_swap_with");
memcpy (&mediator, &pad[source_joypad], sizeof (JoypadBinding));
memcpy (&pad[source_joypad], &pad[dest_joypad], sizeof (JoypadBinding));
memcpy (&pad[dest_joypad], &mediator, sizeof (JoypadBinding));
mediator = pad[source_joypad];
pad[source_joypad] = pad[dest_joypad];
pad[dest_joypad] = mediator;
bindings_to_dialog (source_joypad);
@ -1277,7 +1277,10 @@ Snes9xPreferences::reset_current_joypad (void)
{
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);

View File

@ -850,7 +850,7 @@ Snes9xWindow::open_movie_dialog (bool readonly)
_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"),
GTK_WINDOW (this->window),
@ -1116,7 +1116,7 @@ Snes9xWindow::save_state_dialog ()
_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"),
GTK_WINDOW (this->window),
@ -1194,7 +1194,7 @@ Snes9xWindow::save_spc_dialog ()
_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..."),
GTK_WINDOW (this->window),

View File

@ -284,16 +284,7 @@ namespace JMA
stream.read((char *)int4_buffer, UINT_SIZE);
size_t compressed_size = charp_to_uint(int4_buffer);
//Allocate memory of the correct size to hold the compressed data in the JMA
//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);
}
compressed_buffer = new unsigned char[compressed_size];
//Read all the compressed data in
stream.read((char *)compressed_buffer, compressed_size);
@ -441,17 +432,11 @@ namespace JMA
//Allocate memory for compressed and decompressed data
unsigned char *comp_buffer = 0, *decomp_buffer = 0;
try
{
//Compressed data size is <= non compressed size
unsigned char *combined_buffer = new unsigned char[chunk_size*2];
comp_buffer = combined_buffer;
decomp_buffer = combined_buffer+chunk_size;
}
catch (bad_alloc xa)
{
throw(JMA_NO_MEM_ALLOC);
}
//Compressed data size is <= non compressed size
unsigned char *combined_buffer = new unsigned char[chunk_size*2];
comp_buffer = combined_buffer;
decomp_buffer = combined_buffer+chunk_size;
size_t first_chunk_offset = size_to_skip % chunk_size;
unsigned char int4_buffer[UINT_SIZE];
@ -492,14 +477,7 @@ namespace JMA
else //Solid JMA
{
unsigned char *decomp_buffer = 0;
try
{
decomp_buffer = new unsigned char[get_total_size(files)];
}
catch (bad_alloc xa)
{
throw(JMA_NO_MEM_ALLOC);
}
decomp_buffer = new unsigned char[get_total_size(files)];
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)
{
int Percent = 0;
int len = length;
int chunk = length / 50;
@ -404,8 +403,8 @@ static bool8 S9xNPSSendData (int fd, const uint8 *data, int length)
data += sent;
if (length > 1024)
{
Percent = (uint8) (((length - len) * 100) / length);
#ifdef __WIN32__
int Percent = (uint8) (((length - len) * 100) / length);
PostMessage (GUI.hWnd, WM_USER, Percent, Percent);
Sleep (0);
#endif
@ -1057,12 +1056,15 @@ void S9xNPServerLoop (void *)
bool8 S9xNPStartServer (int port)
{
#ifdef __WIN32__
static int p;
p = port;
#endif
#ifdef NP_DEBUG
printf ("SERVER: Starting server on port %d @%ld\n", port, S9xGetMilliTime () - START);
#endif
p = port;
server_continue = TRUE;
if (S9xNPServerInit (port))
#ifdef __WIN32__

View File

@ -321,8 +321,9 @@ GLuint GLSLShader::compile_shader(char *program,
glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
info_log[0] = '\0';
glGetShaderInfoLog (shader, 1024, NULL, info_log);
if (info_log && *info_log)
if (*info_log)
printf ("%s\n", info_log);
*out = shader;
@ -408,8 +409,9 @@ bool GLSLShader::load_shader (char *filename)
glLinkProgram (p->program);
glGetProgramiv (p->program, GL_LINK_STATUS, &status);
log[0] = '\0';
glGetProgramInfoLog(p->program, 1024, NULL, log);
if (log && *log)
if (*log)
printf ("%s\n", log);
glDeleteShader (vertex_shader);
@ -833,7 +835,7 @@ void GLSLShader::set_shader_vars (unsigned int p)
if (attr > -1) \
{ \
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); \
}
#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];
_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);
S9xFreezeGame(filename);
}