shithub: choc

Download patch

ref: 2e8f6da6fdf0eb71e58d2cdaad24e5b0a332f675
parent: 14c50f0200a382dd5be45b9dca74b6d5e4d89730
author: Fabian Greffrath <fabian@greffrath.com>
date: Fri May 8 04:43:19 EDT 2015

warnings: fix ".. may be used uninitialized in this function" warnings

Actually, it was already impossible for the reported variables to be
used uninitialized, because they were all assigned a value by calling
ReadByte() and the function would return if that failed. However, the
compiler couldn't know about this fact, so we do him the favor and
initialized them to 0.

--- a/src/midifile.c
+++ b/src/midifile.c
@@ -130,7 +130,7 @@
 static boolean ReadVariableLength(unsigned int *result, FILE *stream)
 {
     int i;
-    byte b;
+    byte b = 0;
 
     *result = 0;
 
@@ -203,7 +203,7 @@
                                 byte event_type, boolean two_param,
                                 FILE *stream)
 {
-    byte b;
+    byte b = 0;
 
     // Set basics:
 
@@ -269,7 +269,7 @@
 
 static boolean ReadMetaEvent(midi_event_t *event, FILE *stream)
 {
-    byte b;
+    byte b = 0;
 
     event->event_type = MIDI_EVENT_META;
 
@@ -308,7 +308,7 @@
 static boolean ReadEvent(midi_event_t *event, unsigned int *last_event_type,
                          FILE *stream)
 {
-    byte event_type;
+    byte event_type = 0;
 
     if (!ReadVariableLength(&event->delta_time, stream))
     {