foxygit / doom Log in
commit 37ea28a4550342e8f3bd811888b7f6a021487d55
Author:     Alex Mayfield <alexmax2742@gmail.com>
AuthorDate: Sun Feb 26 17:24:04 2017 -0500
Commit:     Alex Mayfield <alexmax2742@gmail.com>
CommitDate: Sun Feb 26 17:24:04 2017 -0500

    Fix GCC warnings
---
 midiproc/buffer.c | 10 +++++++---
 midiproc/main.c   | 10 ++++++----
 src/i_midipipe.c  |  3 +++
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/midiproc/buffer.c b/midiproc/buffer.c
index 2b96b592..1a1ff3d3 100644
--- a/midiproc/buffer.c
+++ b/midiproc/buffer.c
@@ -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.
diff --git a/midiproc/main.c b/midiproc/main.c
index ff199eb5..983ee23c 100644
--- a/midiproc/main.c
+++ b/midiproc/main.c
@@ -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);

diff --git a/src/i_midipipe.c b/src/i_midipipe.c
index a81fc202..bf38c22a 100644
--- a/src/i_midipipe.c
+++ b/src/i_midipipe.c
@@ -18,6 +18,9 @@

 #if _WIN32

+#include <stdlib.h>
+#include <sys/stat.h>
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>