Commits to SDL revision control. Unmonitored, automated account; try @icculus
or https://github.com/libsdl-org/SDL !


The patch
From deba9f4b8b9533be441cb9bc72a02c998137efb7 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 15 Dec 2022 14:11:08 +0100
Subject: [PATCH] testime.c: fix various warnings + test error code from
 SDL_RWread, changing bytesRead to Sint64 (thanks Ozkan) see #6818

---
 test/testime.c | 54 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/test/testime.c b/test/testime.c
index b5a901efae60..972774961d2b 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -21,7 +21,10 @@
 #include <SDL3/SDL_test_common.h>
 #include "testutils.h"
 
+#ifdef HAVE_SDL_TTF
 #define DEFAULT_PTSIZE 30
+#endif
+
 #ifdef HAVE_SDL_TTF
 #ifdef __MACOS__
 #define DEFAULT_FONT "/System/Library/Fonts/εŽζ–‡η»†ι»‘.ttf"
@@ -56,7 +59,7 @@ static TTF_Font *font;
 #define UNIFONT_TEXTURE_SIZE      (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4)
 #define UNIFONT_TEXTURE_PITCH     (UNIFONT_TEXTURE_WIDTH * 4)
 #define UNIFONT_DRAW_SCALE        2
-struct UnifontGlyph
+static struct UnifontGlyph
 {
     Uint8 width;
     Uint8 data[32];
@@ -104,7 +107,7 @@ static int unifont_init(const char *fontname)
     Uint8 hexBuffer[65];
     Uint32 numGlyphs = 0;
     int lineNumber = 1;
-    size_t bytesRead;
+    Sint64 bytesRead;
     SDL_RWops *hexFile;
     const size_t unifontGlyphSize = UNIFONT_NUM_GLYPHS * sizeof(struct UnifontGlyph);
     const size_t unifontTextureSize = UNIFONT_NUM_TEXTURES * state->num_windows * sizeof(void *);
@@ -141,11 +144,16 @@ static int unifont_init(const char *fontname)
     /* Read all the glyph data into memory to make it accessible later when textures are created. */
     do {
         int i, codepointHexSize;
-        size_t bytesOverread;
+        Sint64 bytesOverread;
         Uint8 glyphWidth;
         Uint32 codepoint;
 
-        bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer, 9);
+        bytesRead = SDL_RWread(hexFile, hexBuffer, 9);
+        if (bytesRead < 0) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "error SDL_RWread\n");
+            return -1;
+        }
+
         if (numGlyphs > 0 && bytesRead == 0) {
             break; /* EOF */
         }
@@ -181,7 +189,13 @@ static int unifont_init(const char *fontname)
         if (codepointHexSize < 8) {
             SDL_memmove(hexBuffer, hexBuffer + codepointHexSize + 1, bytesOverread);
         }
-        bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
+        bytesRead = SDL_RWread(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
+        if (bytesRead < 0) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "error SDL_RWread\n");
+            return -1;
+        }
+
+
         if (bytesRead < (33 - bytesOverread)) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
             return -1;
@@ -190,7 +204,12 @@ static int unifont_init(const char *fontname)
             glyphWidth = 8;
         } else {
             glyphWidth = 16;
-            bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer + 33, 32);
+            bytesRead = SDL_RWread(hexFile, hexBuffer + 33, 32);
+            if (bytesRead < 0) {
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "error SDL_RWread\n");
+                return -1;
+            }
+
             if (bytesRead < 32) {
                 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
                 return -1;
@@ -329,7 +348,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
     return unifontGlyph[codepoint].width;
 }
 
-static void unifont_cleanup()
+static void unifont_cleanup(void)
 {
     int i, j;
     for (i = 0; i < state->num_windows; ++i) {
@@ -356,7 +375,7 @@ static void unifont_cleanup()
 /* Unifont code end */
 #endif
 
-size_t utf8_length(unsigned char c)
+static size_t utf8_length(unsigned char c)
 {
     c = (unsigned char)(0xff & c);
     if (c < 0x80) {
@@ -371,7 +390,8 @@ size_t utf8_length(unsigned char c)
     return 0;
 }
 
-char *utf8_next(char *p)
+#ifdef HAVE_SDL_TTF
+static char *utf8_next(char *p)
 {
     size_t len = utf8_length(*p);
     size_t i = 0;
@@ -388,7 +408,8 @@ char *utf8_next(char *p)
     return p;
 }
 
-char *utf8_advance(char *p, size_t distance)
+
+static char *utf8_advance(char *p, size_t distance)
 {
     size_t i = 0;
     for (; i < distance && p; ++i) {
@@ -396,8 +417,9 @@ char *utf8_advance(char *p, size_t distance)
     }
     return p;
 }
+#endif
 
-Uint32 utf8_decode(char *p, size_t len)
+static Uint32 utf8_decode(char *p, size_t len)
 {
     Uint32 codepoint = 0;
     size_t i = 0;
@@ -421,12 +443,12 @@ Uint32 utf8_decode(char *p, size_t len)
     return codepoint;
 }
 
-void usage()
+static void usage(void)
 {
     SDL_Log("usage: testime [--font fontfile]\n");
 }
 
-void InitInput()
+static void InitInput(void)
 {
     /* Prepare a rect for text input */
     textRect.x = textRect.y = 100;
@@ -440,7 +462,7 @@ void InitInput()
     SDL_StartTextInput();
 }
 
-void CleanupVideo()
+static void CleanupVideo(void)
 {
     SDL_StopTextInput();
 #ifdef HAVE_SDL_TTF
@@ -451,7 +473,7 @@ void CleanupVideo()
 #endif
 }
 
-void _Redraw(int rendererID)
+static void _Redraw(int rendererID)
 {
     SDL_Renderer *renderer = state->renderers[rendererID];
     SDL_Rect drawnTextRect, cursorRect, underlineRect;
@@ -593,7 +615,7 @@ void _Redraw(int rendererID)
     SDL_SetTextInputRect(&markedRect);
 }
 
-void Redraw()
+static void Redraw(void)
 {
     int i;
     for (i = 0; i < state->num_windows; ++i) {



The patch
From 1e6d4649c0ed69d8f6182d6f33825eae700cb915 Mon Sep 17 00:00:00 2001
From: Sylvain Becker <[EMAIL REDACTED]>
Date: Thu, 15 Dec 2022 10:06:15 +0100
Subject: [PATCH]  fixed build rwops (#6818)

* Fixed build
---
 test/testautomation_rwops.c | 4 ++--
 test/testime.c              | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c
index 3c9004c6568e..87b26558150a 100644
--- a/test/testautomation_rwops.c
+++ b/test/testautomation_rwops.c
@@ -440,7 +440,7 @@ int rwops_testCompareRWFromMemWithRWFromFile(void)
         /* Read/seek from memory */
         rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen);
         SDLTest_AssertPass("Call to SDL_RWFromMem()");
-        rv_mem = SDL_RWread(rwops_mem, buffer_mem, size * 6);
+        rv_mem = (size_t)SDL_RWread(rwops_mem, buffer_mem, size * 6);
         SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size * 6);
         sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END);
         SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)");
@@ -451,7 +451,7 @@ int rwops_testCompareRWFromMemWithRWFromFile(void)
         /* Read/see from file */
         rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r");
         SDLTest_AssertPass("Call to SDL_RWFromFile()");
-        rv_file = SDL_RWread(rwops_file, buffer_file, size * 6);
+        rv_file = (size_t)SDL_RWread(rwops_file, buffer_file, size * 6);
         SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size * 6);
         sv_file = SDL_RWseek(rwops_file, 0, SEEK_END);
         SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)");
diff --git a/test/testime.c b/test/testime.c
index f2c13fbdee1d..b5a901efae60 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -145,7 +145,7 @@ static int unifont_init(const char *fontname)
         Uint8 glyphWidth;
         Uint32 codepoint;
 
-        bytesRead = SDL_RWread(hexFile, hexBuffer, 9);
+        bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer, 9);
         if (numGlyphs > 0 && bytesRead == 0) {
             break; /* EOF */
         }
@@ -181,7 +181,7 @@ static int unifont_init(const char *fontname)
         if (codepointHexSize < 8) {
             SDL_memmove(hexBuffer, hexBuffer + codepointHexSize + 1, bytesOverread);
         }
-        bytesRead = SDL_RWread(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
+        bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
         if (bytesRead < (33 - bytesOverread)) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
             return -1;
@@ -190,7 +190,7 @@ static int unifont_init(const char *fontname)
             glyphWidth = 8;
         } else {
             glyphWidth = 16;
-            bytesRead = SDL_RWread(hexFile, hexBuffer + 33, 32);
+            bytesRead = (size_t)SDL_RWread(hexFile, hexBuffer + 33, 32);
             if (bytesRead < 32) {
                 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
                 return -1;



The patch
From c63703129407e8bbd7d48f29836f7038c514b501 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 15 Dec 2022 00:16:02 -0500
Subject: [PATCH] rwops: Fixed another Windows build failure.

---
 src/audio/SDL_wave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 37b13b5d37ef..8d51d9e4a9de 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1553,7 +1553,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
             return -2;
         }
 
-        chunk->size = SDL_RWread(src, chunk->data, length);
+        chunk->size = (size_t) SDL_RWread(src, chunk->data, length);
         if (chunk->size != length) {
             /* Expected to be handled by the caller. */
         }



The patch
From 4075748e41bee51352eb728e1341f22706e39a62 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 15 Dec 2022 00:09:12 -0500
Subject: [PATCH] rwops: Removed unused variable in Windows-specific code.

---
 src/file/SDL_rwops.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index 207e30cd34b5..1850f982a9a2 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -238,7 +238,6 @@ windows_file_write(SDL_RWops *context, const void *ptr, Sint64 size)
 {
     const size_t total_bytes = (size_t) size;
     DWORD byte_written;
-    size_t nwritten;
 
     if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
         return SDL_SetError("Invalid file handle");


Β