]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
fopen: fix conversion warning on 32-bit Android
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Tue, 13 Jun 2023 09:13:59 +0000 (11:13 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 14 Jun 2023 07:31:47 +0000 (09:31 +0200)
When building for 32-bit ARM or x86 Android, `st_mode` is defined as
`unsigned int` instead of `mode_t`, resulting in a
-Wimplicit-int-conversion clang warning because `mode_t` is
`unsigned short`. Add a cast to silence the warning.

Ref: https://android.googlesource.com/platform/bionic/+/refs/tags/ndk-r25c/libc/include/sys/stat.h#86
Closes https://github.com/curl/curl/pull/11313

lib/fopen.c

index f710dbf05ae1d9354e6cc83fbba353849e537c6f..c9c9e3d6e73a266377026773ce2781aa630f747a 100644 (file)
@@ -85,7 +85,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
     if((fstat(fd, &nsb) != -1) &&
        (nsb.st_uid == sb.st_uid) && (nsb.st_gid == sb.st_gid)) {
       /* if the user and group are the same, clone the original mode */
-      if(fchmod(fd, sb.st_mode) == -1)
+      if(fchmod(fd, (mode_t)sb.st_mode) == -1)
         goto fail;
     }
   }