From 1aae3d8edb555ff8767ce7c28057bef37106d059 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 22 Jan 2024 01:01:50 +0300
Subject: [PATCH] sync headers, testlib, and tests with latest SDL2.
---
include/SDL2/SDL_video.h | 5 +++++
src/test/SDL_test_common.c | 7 +++----
test/testautomation_guid.c | 2 +-
test/testautomation_surface.c | 11 +++++++++--
test/testgesture.c | 2 +-
5 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/include/SDL2/SDL_video.h b/include/SDL2/SDL_video.h
index 3e1c8a8..fa47d30 100644
--- a/include/SDL2/SDL_video.h
+++ b/include/SDL2/SDL_video.h
@@ -1341,6 +1341,11 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
*
* This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
*
+ * Note that this function will update _at least_ the rectangles specified,
+ * but this is only intended as an optimization; in practice, this might
+ * update more of the screen (or all of the screen!), depending on what
+ * method SDL uses to send pixels to the system.
+ *
* \param window the window to update
* \param rects an array of SDL_Rect structures representing areas of the
* surface to copy, in pixels
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index d688ea9..04ad51f 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1594,11 +1594,10 @@ static void SDLTest_PrintEvent(SDL_Event *event)
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " restored", event->window.windowID);
break;
case SDL_WINDOWEVENT_ENTER:
- SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32 "",
- event->window.windowID);
+ SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32, event->window.windowID);
break;
case SDL_WINDOWEVENT_LEAVE:
- SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32 "", event->window.windowID);
+ SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32, event->window.windowID);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " gained keyboard focus",
@@ -1621,7 +1620,7 @@ static void SDLTest_PrintEvent(SDL_Event *event)
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " ICC profile changed", event->window.windowID);
break;
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
- SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32 "", event->window.windowID, event->window.data1);
+ SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32, event->window.windowID, event->window.data1);
break;
default:
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " got unknown event 0x%4.4x",
diff --git a/test/testautomation_guid.c b/test/testautomation_guid.c
index cf99dea..81e60e8 100644
--- a/test/testautomation_guid.c
+++ b/test/testautomation_guid.c
@@ -125,7 +125,7 @@ TestGuidToString(void *arg)
SDL_GUIDToString(guid, guid_str, size);
/* Check bytes before guid_str_buf */
- expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (fill_char << 24);
+ expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (((Uint32)fill_char) << 24);
SDL_memcpy(&actual_prefix, guid_str_buf, 4);
SDLTest_AssertCheck(expected_prefix == actual_prefix, "String buffer memory before output untouched, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32 ", at size=%d", expected_prefix, actual_prefix, size);
diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c
index c758bde..fcc4bc1 100644
--- a/test/testautomation_surface.c
+++ b/test/testautomation_surface.c
@@ -765,19 +765,26 @@ int surface_testOverflow(void *arg)
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
if (sizeof(size_t) == 4 && sizeof(int) >= 4) {
+ SDL_ClearError();
expectedError = "Out of memory";
- surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32, 1, 8, SDL_PIXELFORMAT_INDEX8);
+ /* 0x5555'5555 * 3bpp = 0xffff'ffff which fits in size_t, but adding
+ * alignment padding makes it overflow */
+ surface = SDL_CreateRGBSurfaceWithFormat(0, 0x55555555, 1, 24, SDL_PIXELFORMAT_RGB24);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
- surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32 / 2, 1, 32, SDL_PIXELFORMAT_ARGB8888);
+ SDL_ClearError();
+ /* 0x4000'0000 * 4bpp = 0x1'0000'0000 which (just) overflows */
+ surface = SDL_CreateRGBSurfaceWithFormat(0, 0x40000000, 1, 32, SDL_PIXELFORMAT_ARGB8888);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
+ SDL_ClearError();
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 29) - 1, (1 << 29) - 1, 8, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
+ SDL_ClearError();
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 15) + 1, (1 << 15) + 1, 32, SDL_PIXELFORMAT_ARGB8888);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
diff --git a/test/testgesture.c b/test/testgesture.c
index 9bfde2d..9870b60 100644
--- a/test/testgesture.c
+++ b/test/testgesture.c
@@ -251,7 +251,7 @@ loop(void)
break;
case SDL_DOLLARRECORD:
- SDL_Log("Recorded gesture: %" SDL_PRIs64 "", event.dgesture.gestureId);
+ SDL_Log("Recorded gesture: %" SDL_PRIs64, event.dgesture.gestureId);
break;
}
}