]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
formdata: fix warning: 'CURLformoption' is promoted to 'int'
authorzhanghu <zhanghu6@xiaomi.com>
Thu, 22 Apr 2021 09:10:00 +0000 (17:10 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 13 Sep 2022 09:24:40 +0000 (11:24 +0200)
curl/lib/formdata.c: In function 'FormAdd':
curl/lib/formdata.c:249:31: warning: 'CURLformoption' is promoted to 'int' when passed through '...'
  249 |       option = va_arg(params, CURLformoption);
      |                               ^
curl/lib/formdata.c:249:31: note: (so you should pass 'int' not 'CURLformoption' to 'va_arg')
curl/lib/formdata.c:249:31: note: if this code is reached, the program will abort

Closes #9484

.mailmap
lib/formdata.c

index 5fe41e157490ec8911e428961c4732334bae38f1..a8f0cd716f0bf44a77f0e140b91241b8c85a3104 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -96,3 +96,4 @@ Oliver Roberts <oliver@futaura.co.uk>
 opensignature on github <antonio@piumarossa.it>
 Cering on github <gfypm@qq.com>
 a1346054 on github <36859588+a1346054@users.noreply.github.com>
+zhanghu on xiaomi <zhanghu6@xiaomi.com>
index f5ed3653dfabc84a60fa7226950cefe35ee622c1..3128f495b1b702c6a4673bc1ec1562e270da0945 100644 (file)
@@ -251,8 +251,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
       }
     }
     else {
-      /* This is not array-state, get next option */
-      option = va_arg(params, CURLformoption);
+      /* This is not array-state, get next option. This gets an 'int' with
+         va_arg() because CURLformoption might be a smaller type than int and
+         might cause compiler warnings and wrong behavior. */
+      option = va_arg(params, int);
       if(CURLFORM_END == option)
         break;
     }