From e632ed23ad54444f3fccc96ee365bbea397ed3dc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 17 Apr 2024 07:47:29 -0700 Subject: [PATCH] Fixed compilation with C89 (thanks @d-s-a!) Closes https://github.com/libsdl-org/SDL/pull/9564 (cherry picked from commit 4e29be814e2a67992e7487b2b1814e37ff4c6980) --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 3 ++- src/video/wayland/SDL_waylandevents.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 861246e9a1d70..db7784265372e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -76,6 +76,7 @@ static int get_driindex(void) int devindex = -1; DIR *folder; const char *hint; + struct dirent *res; hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX); if (hint && *hint) { @@ -95,7 +96,7 @@ static int get_driindex(void) SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname, sizeof(device) - kmsdrm_dri_devnamesize); - for (struct dirent *res; (res = readdir(folder));) { + while((res = readdir(folder)) != NULL) { if (SDL_memcmp(res->d_name, kmsdrm_dri_devname, kmsdrm_dri_devnamesize) == 0) { SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize, diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 9f679ee82a958..fc9788643554e 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -2164,7 +2164,8 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d char **paths = SDL_DBus_DocumentsPortalRetrieveFiles(buffer, &path_count); /* If dropped files contain a directory the list is empty */ if (paths && path_count > 0) { - for (int i = 0; i < path_count; i++) { + int i; + for (i = 0; i < path_count; i++) { SDL_SendDropFile(data_device->dnd_window, NULL, paths[i]); } dbus->free_string_array(paths);