Просмотр исходного кода

wayland: don't redeclare getresuid/getresgid

When HAVE_GETRESUID/HAVE_GETRESGID are not defined, SDL_waylandvideo.c defines
static inline fallbacks using the libc names. glibc declares both functions
non-static in <unistd.h>, so on a toolchain where the feature checks fail while
those declarations are still visible the file fails to compile:

  error: static declaration of 'getresuid' follows non-static declaration

Give the fallbacks SDL-private names and call those, so a fallback can never
collide with a libc declaration. Also fixes the fallback getresgid() taking
uid_t* parameters where it should take gid_t*.
janusch 1 месяц назад
Родитель
Сommit
c15b6a1457
1 измененных файлов с 10 добавлено и 6 удалено
  1. 10 6
      src/video/wayland/SDL_waylandvideo.c

+ 10 - 6
src/video/wayland/SDL_waylandvideo.c

@@ -1604,19 +1604,23 @@ static int SDLCALL LibdecorNewInThread(void *data)
 }
 }
 #endif
 #endif
 
 
-#ifndef HAVE_GETRESUID
+#ifdef HAVE_GETRESUID
+#define SDL_getresuid getresuid
+#else
 // Non-POSIX, but Linux and some BSDs have it.
 // Non-POSIX, but Linux and some BSDs have it.
 // To reduce the number of code paths, if getresuid() isn't available at
 // To reduce the number of code paths, if getresuid() isn't available at
 // compile-time, we behave as though it existed but failed at runtime.
 // compile-time, we behave as though it existed but failed at runtime.
-static inline int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) {
+static inline int SDL_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) {
     errno = ENOSYS;
     errno = ENOSYS;
     return -1;
     return -1;
 }
 }
 #endif
 #endif
 
 
-#ifndef HAVE_GETRESGID
+#ifdef HAVE_GETRESGID
+#define SDL_getresgid getresgid
+#else
 // Same as getresuid() but for the primary group
 // Same as getresuid() but for the primary group
-static inline int getresgid(uid_t *ruid, uid_t *euid, uid_t *suid) {
+static inline int SDL_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) {
     errno = ENOSYS;
     errno = ENOSYS;
     return -1;
     return -1;
 }
 }
@@ -1638,12 +1642,12 @@ bool CanUseGtk(void)
     // we don't use Linux getauxval() or prctl PR_GET_DUMPABLE,
     // we don't use Linux getauxval() or prctl PR_GET_DUMPABLE,
     // BSD issetugid(), or similar OS-specific detection
     // BSD issetugid(), or similar OS-specific detection
 
 
-    if (getresuid(&ruid, &euid, &suid) != 0) {
+    if (SDL_getresuid(&ruid, &euid, &suid) != 0) {
         ruid = suid = getuid();
         ruid = suid = getuid();
         euid = geteuid();
         euid = geteuid();
     }
     }
 
 
-    if (getresgid(&rgid, &egid, &sgid) != 0) {
+    if (SDL_getresgid(&rgid, &egid, &sgid) != 0) {
         rgid = sgid = getgid();
         rgid = sgid = getgid();
         egid = getegid();
         egid = getegid();
     }
     }