SDL_mixer: load_voc.c: invent and use new VOC_BAD_RATE macro instead of (-1).

From e108de78d4c32ba98cb333aa8663ebf345572d56 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 18 Nov 2019 18:50:50 +0300
Subject: [PATCH] load_voc.c: invent and use new VOC_BAD_RATE macro instead of
 (-1).

(cherry picked from commit 77ed762c9298b6047bd0bd497f693f4f50cf8ff8)
---
 load_voc.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/load_voc.c b/load_voc.c
index eb3131ee..f12d4d6e 100644
--- a/load_voc.c
+++ b/load_voc.c
@@ -85,6 +85,8 @@ typedef struct vocstuff {
 #define VOC_EXTENDED    8
 #define VOC_DATA_16	9
 
+#define VOC_BAD_RATE  ~((Uint32)0)
+
 
 static int voc_check_header(SDL_RWops *src)
 {
@@ -158,7 +160,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                         return 0;
                     }
 
-                    if ((v->rate != -1) && (uc != v->rate))
+                    if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
                     {
                         SDL_SetError("VOC sample rate codes differ");
                         return 0;
@@ -192,7 +194,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                     SDL_SetError("VOC Sample rate is zero?");
                     return 0;
                 }
-                if ((v->rate != -1) && (new_rate_long != v->rate))
+                if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate))
                 {
                     SDL_SetError("VOC sample rate codes differ");
                     return 0;
@@ -243,7 +245,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                  * different sample rate codes in silence.
                  * Adjust period.
                  */
-                if ((v->rate != -1) && (uc != v->rate))
+                if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
                     period = (Uint16)((period * (256 - uc))/(256 - v->rate));
                 else
                     v->rate = uc;
@@ -274,7 +276,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                    SDL_SetError("VOC sample rate is zero");
                    return 0;
                 }
-                if ((v->rate != -1) && (new_rate_short != v->rate))
+                if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate))
                 {
                    SDL_SetError("VOC sample rate codes differ");
                    return 0;
@@ -390,7 +392,7 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
     if ( !voc_check_header(src) )
         goto done;
 
-    v.rate = -1;
+    v.rate = VOC_BAD_RATE;
     v.rest = 0;
     v.has_extended = 0;
     *audio_buf = NULL;
@@ -400,8 +402,7 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
     if (!voc_get_block(src, &v, spec))
         goto done;
 
-    if (v.rate == -1)
-    {
+    if (v.rate == VOC_BAD_RATE) {
         SDL_SetError("VOC data had no sound!");
         goto done;
     }
@@ -442,7 +443,7 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
 
     /* Don't return a buffer that isn't a multiple of samplesize */
     samplesize = ((spec->format & 0xFF)/8)*spec->channels;
-    *audio_len &= ~(samplesize-1);
+    *audio_len &= (Uint32) ~(samplesize-1);
 
 done:
     if (src)