Commit fae7034901365b19c0996ad0041a9c6ff5ef3ae1

Sylvain 2021-11-23T10:33:12

Fix warnings: static, include, un-initialized vairables

diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c
index 792943f..1519f5c 100644
--- a/src/core/linux/SDL_fcitx.c
+++ b/src/core/linux/SDL_fcitx.c
@@ -84,7 +84,8 @@ GetAppName()
     return SDL_strdup("SDL_App");
 }
 
-size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
+static size_t
+Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
     char *text = NULL, *subtext;
     size_t text_bytes = 0;
     DBusMessageIter iter, array, sub;
diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c
index 7933d49..1683c0e 100644
--- a/src/core/linux/SDL_ime.c
+++ b/src/core/linux/SDL_ime.c
@@ -23,13 +23,13 @@
 #include "SDL_ibus.h"
 #include "SDL_fcitx.h"
 
-typedef SDL_bool (*_SDL_IME_Init)();
-typedef void (*_SDL_IME_Quit)();
+typedef SDL_bool (*_SDL_IME_Init)(void);
+typedef void (*_SDL_IME_Quit)(void);
 typedef void (*_SDL_IME_SetFocus)(SDL_bool);
-typedef void (*_SDL_IME_Reset)();
+typedef void (*_SDL_IME_Reset)(void);
 typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32);
 typedef void (*_SDL_IME_UpdateTextRect)(SDL_Rect *);
-typedef void (*_SDL_IME_PumpEvents)();
+typedef void (*_SDL_IME_PumpEvents)(void);
 
 static _SDL_IME_Init SDL_IME_Init_Real = NULL;
 static _SDL_IME_Quit SDL_IME_Quit_Real = NULL;
diff --git a/src/misc/unix/SDL_sysurl.c b/src/misc/unix/SDL_sysurl.c
index 198b425..0163813 100644
--- a/src/misc/unix/SDL_sysurl.c
+++ b/src/misc/unix/SDL_sysurl.c
@@ -65,8 +65,6 @@ SDL_SYS_OpenURL(const char *url)
             return SDL_SetError("Waiting on xdg-open failed: %s", strerror(errno));
         }
     }
-
-    return 0;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c
index 009e23d..af4e457 100644
--- a/src/test/SDL_test_random.c
+++ b/src/test/SDL_test_random.c
@@ -83,7 +83,8 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
 
   if (rndContext==NULL) return -1;
 
-  xh = rndContext->x >> 16, xl = rndContext->x & 65535;
+  xh = rndContext->x >> 16;
+  xl = rndContext->x & 65535;
   rndContext->x = rndContext->x * rndContext->a + rndContext->c;
   rndContext->c =
     xh * rndContext->ah + ((xh * rndContext->al) >> 16) +
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 08e51ae..b459090 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -119,7 +119,7 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
 } 
 
 /* Remove a cursor buffer from a display's DRM cursor BO. */
-int
+static int
 KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
 {
     int ret = 0;
@@ -138,7 +138,7 @@ KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
 }
 
 /* Dump a cursor buffer to a display's DRM cursor BO.  */
-int
+static int
 KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
 {
     SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata;
@@ -403,8 +403,6 @@ KMSDRM_WarpMouseGlobal(int x, int y)
     } else {
         return SDL_SetError("No mouse or current cursor.");
     }
-
-    return 0;
 }
 
 void
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.h b/src/video/kmsdrm/SDL_kmsdrmmouse.h
index 36625ac..8bef48b 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.h
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.h
@@ -48,7 +48,7 @@ extern void KMSDRM_QuitMouse(_THIS);
 
 extern void KMSDRM_CreateCursorBO(SDL_VideoDisplay *display);
 extern void KMSDRM_DestroyCursorBO(_THIS, SDL_VideoDisplay *display);
-extern void KMSDRM_InitCursor();
+extern void KMSDRM_InitCursor(void);
 
 #endif /* SDL_KMSDRM_mouse_h_ */
 
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 9b71609..dbc1b44 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -471,7 +471,7 @@ KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) {
    available on the DRM connector of the display.
    We use the SDL mode list (which we filled in KMSDRM_GetDisplayModes)
    because it's ordered, while the list on the connector is mostly random.*/
-drmModeModeInfo*
+static drmModeModeInfo*
 KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay * display,
 uint32_t width, uint32_t height, uint32_t refresh_rate){
 
@@ -502,7 +502,8 @@ uint32_t width, uint32_t height, uint32_t refresh_rate){
 /*****************************************************************************/
 
 /* Deinitializes the driverdata of the SDL Displays in the SDL display list. */
-void KMSDRM_DeinitDisplays (_THIS) {
+static void
+KMSDRM_DeinitDisplays (_THIS) {
 
     SDL_DisplayData *dispdata;
     int num_displays, i;
@@ -531,7 +532,8 @@ void KMSDRM_DeinitDisplays (_THIS) {
 
 /* Gets a DRM connector, builds an SDL_Display with it, and adds it to the
    list of SDL Displays in _this->displays[]  */
-void KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
+static void
+KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
 
     SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
     SDL_DisplayData *dispdata = NULL;
@@ -719,7 +721,8 @@ cleanup:
    closed when we get to the end of this function.
    This is to be called early, in VideoInit(), because it gets us
    the videomode information, which SDL needs immediately after VideoInit(). */
-int KMSDRM_InitDisplays (_THIS) {
+static int
+KMSDRM_InitDisplays (_THIS) {
 
     SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
     drmModeRes *resources = NULL;
@@ -813,7 +816,7 @@ cleanup:
    These things are incompatible with Vulkan, which accesses the same resources
    internally so they must be free when trying to build a Vulkan surface.
 */
-int
+static int
 KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata)
 {
     SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
@@ -837,7 +840,7 @@ KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata)
 }
 
 /* Deinit the Vulkan-incompatible KMSDRM stuff. */
-void
+static void
 KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata)
 {
     SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
@@ -858,7 +861,7 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata)
     viddata->gbm_init = SDL_FALSE;
 }
 
-void
+static void
 KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
 {
     SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
index 390271e..2a5897a 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
@@ -182,7 +182,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
                                   VkInstance instance,
                                   VkSurfaceKHR *surface)
 {
-    VkPhysicalDevice gpu;
+    VkPhysicalDevice gpu = NULL;
     uint32_t gpu_count;
     uint32_t display_count;
     uint32_t mode_count;
diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c
index 789273b..f43f63f 100644
--- a/src/video/wayland/SDL_waylandclipboard.c
+++ b/src/video/wayland/SDL_waylandclipboard.c
@@ -24,6 +24,7 @@
 
 #include "SDL_waylanddatamanager.h"
 #include "SDL_waylandevents_c.h"
+#include "SDL_waylandclipboard.h"
 
 int
 Wayland_SetClipboardText(_THIS, const char *text)
diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c
index a612ef7..c9a6563 100644
--- a/src/video/wayland/SDL_waylandmessagebox.c
+++ b/src/video/wayland/SDL_waylandmessagebox.c
@@ -31,6 +31,8 @@
 #include <string.h> /* strerr */
 #include <errno.h>
 
+#include "SDL_waylandmessagebox.h"
+
 #define MAX_BUTTONS             8       /* Maximum number of buttons supported */
 
 int
@@ -186,7 +188,6 @@ Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
             return SDL_SetError("Waiting on zenity failed: %s", strerror(errno));
         }
     }
-    return 0;
 }
 
 #endif /* SDL_VIDEO_DRIVER_WAYLAND */
diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index 67ab721..73f6a50 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -38,7 +38,7 @@
 #include "SDL_waylandevents_c.h"
 
 #include "wayland-cursor.h"
-
+#include "SDL_waylandmouse.h"
 
 
 typedef struct {
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 1b3e693..8c0d31d 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -1693,7 +1693,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
         if (!data->videodata->broken_pointer_grab) {
             const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
             int attempts;
-            int result;
+            int result = 0;
 
             /* Try for up to 5000ms (5s) to grab. If it still fails, stop trying. */
             for (attempts = 0; attempts < 100; attempts++) {