shithub: choc

Download patch

ref: f09202ec5a79a7f8fb9464bcd92833645f23d03e
parent: e6260bfe98c4f3131a1512a0dd7ab2244db1b32e
author: Alex Mayfield <alexmax2742@gmail.com>
date: Mon Mar 13 18:56:43 EDT 2017

Style fixes

--- a/midiproc/main.c
+++ b/midiproc/main.c
@@ -163,7 +163,7 @@
     buffer[1] = i & 0xff;
 
     WriteFile(midi_process_out, buffer, sizeof(buffer),
-        &bytes_written, NULL);
+              &bytes_written, NULL);
 
     return true;
 }
@@ -287,7 +287,7 @@
     {
         // Wait until we see some data on the pipe.
         wok = PeekNamedPipe(midi_process_in, NULL, 0, NULL,
-            &pipe_buffer_read, NULL);
+                            &pipe_buffer_read, NULL);
         if (!wok)
         {
             break;
@@ -300,7 +300,7 @@
 
         // Read data off the pipe and add it to the buffer.
         wok = ReadFile(midi_process_in, pipe_buffer, sizeof(pipe_buffer),
-            &pipe_buffer_read, NULL);
+                       &pipe_buffer_read, NULL);
         if (!wok)
         {
             break;
@@ -389,9 +389,9 @@
     if (argc < 3)
     {
         MessageBox(NULL, TEXT("This program is tasked with playing Native ")
-            TEXT("MIDI music, and is intended to be launched by ")
-            TEXT(PACKAGE_NAME) TEXT("."),
-            TEXT(PACKAGE_STRING), MB_OK | MB_ICONASTERISK);
+                   TEXT("MIDI music, and is intended to be launched by ")
+                   TEXT(PACKAGE_NAME) TEXT("."),
+                   TEXT(PACKAGE_STRING), MB_OK | MB_ICONASTERISK);
 
         return EXIT_FAILURE;
     }
@@ -401,15 +401,15 @@
     {
         char message[1024];
         snprintf(message, sizeof(message),
-            "It appears that the version of %s and %smidiproc are out of "
-            " sync.  Please reinstall %s.\r\n\r\n"
-            "Server Version: %s\r\nClient Version: %s",
-            PACKAGE_NAME, PROGRAM_PREFIX, PACKAGE_NAME,
-            PACKAGE_STRING, argv[1]);
+                 "It appears that the version of %s and %smidiproc are out of "
+                 " sync.  Please reinstall %s.\r\n\r\n"
+                 "Server Version: %s\r\nClient Version: %s",
+                 PACKAGE_NAME, PROGRAM_PREFIX, PACKAGE_NAME,
+                 PACKAGE_STRING, argv[1]);
         message[sizeof(message) - 1] = '\0';
 
         MessageBox(NULL, TEXT(message),
-            TEXT(PACKAGE_STRING), MB_OK | MB_ICONASTERISK);
+                   TEXT(PACKAGE_STRING), MB_OK | MB_ICONASTERISK);
 
         return EXIT_FAILURE;
     }
--- a/src/i_midipipe.c
+++ b/src/i_midipipe.c
@@ -107,9 +107,10 @@
 //
 static boolean UsingNativeMidi()
 {
+    int i;
     int decoders = Mix_GetNumMusicDecoders();
 
-    for (int i = 0;i < decoders;i++)
+    for (i = 0; i < decoders; i++)
     {
         if (strcmp(Mix_GetMusicDecoder(i), "NATIVEMIDI") == 0)
         {
@@ -129,14 +130,9 @@
 {
     DWORD bytes_written;
     BOOL ok = WriteFile(midi_process_in_writer, packet->data, packet->len,
-        &bytes_written, NULL);
+                        &bytes_written, NULL);
 
-    if (!ok)
-    {
-        return false;
-    }
-
-    return true;
+    return ok;
 }
 
 //
@@ -166,10 +162,10 @@
     {
         // Wait until we see exactly the amount of data we expect on the pipe.
         ok = PeekNamedPipe(midi_process_out_reader, NULL, 0, NULL,
-            &pipe_buffer_read, NULL);
+                           &pipe_buffer_read, NULL);
         if (!ok)
         {
-            goto fail;
+            break;
         }
         else if (pipe_buffer_read < packet->len)
         {
@@ -179,16 +175,16 @@
 
         // Read precisely the number of bytes we're expecting, and no more.
         ok = ReadFile(midi_process_out_reader, pipe_buffer, packet->len,
-            &pipe_buffer_read, NULL);
+                      &pipe_buffer_read, NULL);
         if (!ok || pipe_buffer_read != packet->len)
         {
-            goto fail;
+            break;
         }
 
         // Compare our data buffer to the packet.
         if (memcmp(packet->data, pipe_buffer, packet->len) != 0)
         {
-            goto fail;
+            break;
         }
 
         return true;
@@ -196,7 +192,6 @@
         // Continue looping as long as we don't exceed our maximum wait time.
     } while (I_GetTimeMS() - start <= MIDIPIPE_MAX_WAIT);
 
-fail:
     // TODO: Deal with the wedged process?
     return false;
 }
@@ -411,9 +406,9 @@
     // Define the command line.  Version and Sample Rate follow the
     // executable name.
     M_snprintf(snd_samplerate_buf, sizeof(snd_samplerate_buf),
-        "%d", snd_samplerate);
+               "%d", snd_samplerate);
     cmdline = M_StringJoin(module, " \"" PACKAGE_STRING "\"", " ",
-        snd_samplerate_buf, NULL);
+                           snd_samplerate_buf, NULL);
 
     // Set up pipes
     memset(&sec_attrs, 0, sizeof(SECURITY_ATTRIBUTES));
@@ -454,11 +449,14 @@
     startup_info.dwFlags = STARTF_USESTDHANDLES;
 
     ok = CreateProcess(TEXT(module), TEXT(cmdline), NULL, NULL, TRUE,
-        0, NULL, dirname, &startup_info, &proc_info);
+                       0, NULL, dirname, &startup_info, &proc_info);
 
     if (!ok)
     {
-        goto fail;
+        FreePipes();
+        free(cmdline);
+
+        return false;
     }
 
     // Since the server has these handles, we don't need them anymore.
@@ -469,12 +467,6 @@
 
     midi_server_initialized = true;
     return true;
-
-fail:
-    FreePipes();
-    free(cmdline);
-
-    return false;
 }
 
 #endif