SDL: Fixed Xcode build warnings

From c79462dc50f9a050bbb55b6703ba53d74110f6f1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 6 Feb 2024 08:52:37 -0800
Subject: [PATCH] Fixed Xcode build warnings

---
 src/audio/coreaudio/SDL_coreaudio.m    |  4 ++--
 src/joystick/apple/SDL_mfijoystick.m   |  2 +-
 src/render/metal/SDL_render_metal.m    | 19 ++++---------------
 src/video/uikit/SDL_uikitappdelegate.m |  2 +-
 4 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index e376e82bd5b1..c38fa520bb1a 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -849,10 +849,10 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
         #ifdef SDL_PLATFORM_TVOS
         if (device->iscapture) {
             [session setPreferredInputNumberOfChannels:device->spec.channels error:nil];
-            device->spec.channels = session.preferredInputNumberOfChannels;
+            device->spec.channels = (int)session.preferredInputNumberOfChannels;
         } else {
             [session setPreferredOutputNumberOfChannels:device->spec.channels error:nil];
-            device->spec.channels = session.preferredOutputNumberOfChannels;
+            device->spec.channels = (int)session.preferredOutputNumberOfChannels;
         }
         #else
         // Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS
diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m
index e6a799f4796d..cecea10857da 100644
--- a/src/joystick/apple/SDL_mfijoystick.m
+++ b/src/joystick/apple/SDL_mfijoystick.m
@@ -546,7 +546,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
 #ifdef SDL_PLATFORM_TVOS
         /* tvOS turns the menu button into a system gesture, so we grab it here instead */
         if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) {
-            device->pause_button_index = [device->buttons indexOfObject:GCInputButtonMenu];
+            device->pause_button_index = (int)[device->buttons indexOfObject:GCInputButtonMenu];
         }
 #endif
     } else
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 876b1b5f8156..e3d5bf234037 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -1226,8 +1226,6 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
     SDL_bool viewport_dirty;
     SDL_Rect viewport;
     size_t projection_offset;
-    SDL_bool color_dirty;
-    size_t color_offset;
     SDL_bool color_scale_dirty;
     size_t color_scale_offset;
 } METAL_DrawStateCache;
@@ -1290,16 +1288,9 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm
         statecache->cliprect_dirty = SDL_FALSE;
     }
 
-#if 0 /* Not used... */
-    if (statecache->color_dirty) {
-        [data.mtlcmdencoder setFragmentBufferOffset:statecache->color_offset atIndex:0];
-        statecache->color_dirty = SDL_FALSE;
-    }
-#endif
-
     if (statecache->color_scale_dirty) {
         [data.mtlcmdencoder setFragmentBufferOffset:statecache->color_scale_offset atIndex:0];
-        statecache->color_dirty = SDL_FALSE;
+        statecache->color_scale_dirty = SDL_FALSE;
     }
 
     newpipeline = ChoosePipelineState(data, data.activepipelines, shader, blend);
@@ -1368,11 +1359,11 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
         statecache.vertex_buffer = nil;
         statecache.constants_offset = CONSTANTS_OFFSET_INVALID;
         statecache.texture = NULL;
-        statecache.color_dirty = SDL_TRUE;
+        statecache.color_scale_dirty = SDL_TRUE;
         statecache.cliprect_dirty = SDL_TRUE;
         statecache.viewport_dirty = SDL_TRUE;
         statecache.projection_offset = 0;
-        statecache.color_offset = 0;
+        statecache.color_scale_offset = 0;
 
         // !!! FIXME: have a ring of pre-made MTLBuffers we cycle through? How expensive is creation?
         if (vertsize > 0) {
@@ -1417,8 +1408,6 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
 
             case SDL_RENDERCMD_SETDRAWCOLOR:
             {
-                statecache.color_offset = cmd->data.color.first;
-                statecache.color_dirty = SDL_TRUE;
                 break;
             }
 
@@ -1447,7 +1436,7 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
                 statecache.pipeline = nil;
                 statecache.constants_offset = CONSTANTS_OFFSET_INVALID;
                 statecache.texture = NULL;
-                statecache.color_dirty = SDL_TRUE;
+                statecache.color_scale_dirty = SDL_TRUE;
                 statecache.cliprect_dirty = SDL_TRUE;
                 statecache.viewport_dirty = SDL_TRUE;
 
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 0ab30234ccb2..914c27a8b8ae 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -508,7 +508,7 @@ - (void)setWindow:(UIWindow *)window
 - (void)sendDropFileForURL:(NSURL *)url fromSourceApplication:(NSString *)sourceApplication
 {
     NSURL *fileURL = url.filePathURL;
-    char *sourceApplicationCString = sourceApplication ? [sourceApplication UTF8String] : NULL;
+    const char *sourceApplicationCString = sourceApplication ? [sourceApplication UTF8String] : NULL;
     if (fileURL != nil) {
         SDL_SendDropFile(NULL, sourceApplicationCString, fileURL.path.UTF8String);
     } else {