Fix GCC warnings

This commit is contained in:
Alex Mayfield 2017-02-26 17:24:04 -05:00
parent 9f9d647297
commit 37ea28a455
3 changed files with 16 additions and 7 deletions

View file

@ -56,14 +56,16 @@ int Buffer_Data(buffer_t *buf, byte **data)
//
boolean Buffer_Push(buffer_t *buf, const void *data, int len)
{
ptrdiff_t space_begin, space_end;
if (len <= 0)
{
// Do nothing, successfully.
return true;
}
ptrdiff_t space_begin = buf->data - buf->buffer;
ptrdiff_t space_end = buf->buffer_end - buf->data_end;
space_begin = buf->data - buf->buffer;
space_end = buf->buffer_end - buf->data_end;
if (len > space_end)
{
@ -93,13 +95,15 @@ boolean Buffer_Push(buffer_t *buf, const void *data, int len)
//
void Buffer_Shift(buffer_t *buf, int len)
{
ptrdiff_t max_shift;
if (len <= 0)
{
// Do nothing.
return;
}
ptrdiff_t max_shift = buf->data_end - buf->data;
max_shift = buf->data_end - buf->data;
if (len >= max_shift)
{
// If the operation would clear the buffer, just zero everything.

View file

@ -41,7 +41,6 @@
static HANDLE midi_process_in; // Standard In.
static HANDLE midi_process_out; // Standard Out.
static buffer_t *midi_buffer; // Data from client.
// Currently playing music track.
static Mix_Music *music = NULL;
@ -154,6 +153,9 @@ static void StopSong()
static boolean MidiPipe_RegisterSong(buffer_reader_t *reader)
{
unsigned int i;
CHAR buffer[2];
char *filename = Reader_ReadString(reader);
if (filename == NULL)
{
@ -164,8 +166,7 @@ static boolean MidiPipe_RegisterSong(buffer_reader_t *reader)
// FIXME: We should probably have a function for writing Int16's into
// buffers, as opposed to simply winging it.
unsigned int i = NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK;
CHAR buffer[2];
i = NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK;
buffer[0] = (i >> 8) & 0xff;
buffer[1] = i & 0xff;
@ -247,6 +248,7 @@ boolean ParseCommand(buffer_reader_t *reader, uint16_t command)
//
boolean ParseMessage(buffer_t *buf)
{
int bytes_read;
uint16_t command;
buffer_reader_t *reader = NewReader(buf);
@ -264,7 +266,7 @@ boolean ParseMessage(buffer_t *buf)
// We parsed a complete message! We can now safely shift
// the prior message off the front of the buffer.
int bytes_read = Reader_BytesRead(reader);
bytes_read = Reader_BytesRead(reader);
DeleteReader(reader);
Buffer_Shift(buf, bytes_read);

View file

@ -18,6 +18,9 @@
#if _WIN32
#include <stdlib.h>
#include <sys/stat.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>