]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: tidy up deprecation suppression, enable warnings for clang
authorViktor Szakats <commit@vsz.me>
Thu, 5 Sep 2024 00:11:35 +0000 (02:11 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 20 Sep 2024 22:59:52 +0000 (00:59 +0200)
Suppress deprecation warnings the closest to the deprecated code, using
`CURL_IGNORE_DEPRECATION()`. Then drop build-specific suppressions, and
file-wide ones. The latter is not compatible with Unity mode. Also
replace manual suppressions with a macro to apply to all compilers with
deprecation warning support. Also enable deprecation warnings for clang.

- curl/curl.h: enable deprecation warnings for clang.

- docs/examples: stop setting `CURL_DISABLE_DEPRECATION` with autotools.
  Suppression moved to C-level earlier. Syncs with cmake.
  Follow-up to 5fc61a37c1b177cefbc11dc9f5eef7b2a14538da #14123

- tests/http/clients: stop setting `CURL_DISABLE_DEPRECATION` in
  autotools. If it becomes necessary in the future, it can be done in
  C via the macro. Syncs with cmake.

- lib1545: stop setting `CURL_DISABLE_DEPRECATION` in autotools.
  Drop guard from test source.
  Follow-up to 0f103600731f7e08637017ef4df67a194e0d6711 #12444

- libtest, unit: replace `CURL_DISABLE_DEPRECATION` with
  `CURL_IGNORE_DEPRECATION()`.

- docs/examples: replace pragmas with `CURL_IGNORE_DEPRECATION()`.

Closes #14789

13 files changed:
docs/examples/Makefile.am
docs/examples/multi-formadd.c
docs/examples/postit2-formadd.c
include/curl/curl.h
tests/http/clients/Makefile.am
tests/libtest/Makefile.inc
tests/libtest/lib1545.c
tests/libtest/lib554.c
tests/libtest/lib650.c
tests/libtest/lib651.c
tests/libtest/lib670.c
tests/libtest/mk-lib1521.pl
tests/unit/unit1308.c

index 91f90cf65bca1f89743c2fcccfd071a739b171cc..e5ff9ffdcf0e89c804d2c93027d18557937badbc 100644 (file)
@@ -34,8 +34,7 @@ EXTRA_DIST = README.md Makefile.example Makefile.mk CMakeLists.txt \
 #
 # $(top_srcdir)/include is for libcurl's external include files
 
-AM_CPPFLAGS = -I$(top_srcdir)/include   \
-              -DCURL_DISABLE_DEPRECATION
+AM_CPPFLAGS = -I$(top_srcdir)/include
 
 LIBDIR = $(top_builddir)/lib
 
index 6a927bba7b5c505b706bc7443dd5c57220edb0c3..58c7e641c4a1a3b4e46a9c6d38e4edad3cf1293e 100644 (file)
 
 #include <curl/curl.h>
 
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
 int main(void)
 {
   CURL *curl;
@@ -53,27 +48,29 @@ int main(void)
   struct curl_slist *headerlist = NULL;
   static const char buf[] = "Expect:";
 
-  /* Fill in the file upload field. This makes libcurl load data from
-     the given file name when curl_easy_perform() is called. */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "sendfile",
-               CURLFORM_FILE, "multi-formadd.c",
-               CURLFORM_END);
-
-  /* Fill in the filename field */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "filename",
-               CURLFORM_COPYCONTENTS, "multi-formadd.c",
-               CURLFORM_END);
-
-  /* Fill in the submit field too, even if this is rarely needed */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "submit",
-               CURLFORM_COPYCONTENTS, "send",
-               CURLFORM_END);
+  CURL_IGNORE_DEPRECATION(
+    /* Fill in the file upload field. This makes libcurl load data from
+       the given file name when curl_easy_perform() is called. */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "sendfile",
+                 CURLFORM_FILE, "multi-formadd.c",
+                 CURLFORM_END);
+
+    /* Fill in the filename field */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "filename",
+                 CURLFORM_COPYCONTENTS, "multi-formadd.c",
+                 CURLFORM_END);
+
+    /* Fill in the submit field too, even if this is rarely needed */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "submit",
+                 CURLFORM_COPYCONTENTS, "send",
+                 CURLFORM_END);
+  )
 
   curl = curl_easy_init();
   multi_handle = curl_multi_init();
@@ -88,7 +85,9 @@ int main(void)
     curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
     curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
-    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    CURL_IGNORE_DEPRECATION(
+      curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    )
 
     curl_multi_add_handle(multi_handle, curl);
 
@@ -109,15 +108,13 @@ int main(void)
     /* always cleanup */
     curl_easy_cleanup(curl);
 
-    /* then cleanup the formpost chain */
-    curl_formfree(formpost);
+    CURL_IGNORE_DEPRECATION(
+      /* then cleanup the formpost chain */
+      curl_formfree(formpost);
+    )
 
     /* free slist */
     curl_slist_free_all(headerlist);
   }
   return 0;
 }
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
index 6000245b1f509721035064556ffc8f96c1b2d07e..0d9034612a56b60d4e9f5a4b74153a4a9d048fe2 100644 (file)
 
 #include <curl/curl.h>
 
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
 int main(int argc, char *argv[])
 {
   CURL *curl;
@@ -64,27 +59,29 @@ int main(int argc, char *argv[])
 
   curl_global_init(CURL_GLOBAL_ALL);
 
-  /* Fill in the file upload field */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "sendfile",
-               CURLFORM_FILE, "postit2-formadd.c",
-               CURLFORM_END);
-
-  /* Fill in the filename field */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "filename",
-               CURLFORM_COPYCONTENTS, "postit2-formadd.c",
-               CURLFORM_END);
-
-
-  /* Fill in the submit field too, even if this is rarely needed */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "submit",
-               CURLFORM_COPYCONTENTS, "send",
-               CURLFORM_END);
+  CURL_IGNORE_DEPRECATION(
+    /* Fill in the file upload field */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "sendfile",
+                 CURLFORM_FILE, "postit2-formadd.c",
+                 CURLFORM_END);
+
+    /* Fill in the filename field */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "filename",
+                 CURLFORM_COPYCONTENTS, "postit2-formadd.c",
+                 CURLFORM_END);
+
+
+    /* Fill in the submit field too, even if this is rarely needed */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "submit",
+                 CURLFORM_COPYCONTENTS, "send",
+                 CURLFORM_END);
+  )
 
   curl = curl_easy_init();
   /* initialize custom header list (stating that Expect: 100-continue is not
@@ -96,7 +93,9 @@ int main(int argc, char *argv[])
     if((argc == 2) && (!strcmp(argv[1], "noexpectheader")))
       /* only disable 100-continue header if explicitly requested */
       curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
-    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    CURL_IGNORE_DEPRECATION(
+      curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    )
 
     /* Perform the request, res gets the return code */
     res = curl_easy_perform(curl);
@@ -108,14 +107,13 @@ int main(int argc, char *argv[])
     /* always cleanup */
     curl_easy_cleanup(curl);
 
-    /* then cleanup the formpost chain */
-    curl_formfree(formpost);
+    CURL_IGNORE_DEPRECATION(
+      /* then cleanup the formpost chain */
+      curl_formfree(formpost);
+    )
+
     /* free slist */
     curl_slist_free_all(headerlist);
   }
   return 0;
 }
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
index c4fae4d4463b8bf365b01e24c8d548f058ec69fd..043b7103e8c4f98444987e93cdc987407dea0de6 100644 (file)
 #endif
 
 /* Compile-time deprecation macros. */
-#if (defined(__GNUC__) &&                                               \
-  ((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1 ))) ||  \
-  defined(__IAR_SYSTEMS_ICC__)) &&                                      \
-  !defined(__INTEL_COMPILER) &&                                         \
+#if (defined(__GNUC__) &&                                              \
+  ((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1))) ||  \
+  (defined(__clang__) && __clang_major__ >= 3) ||                      \
+  defined(__IAR_SYSTEMS_ICC__)) &&                                     \
+  !defined(__INTEL_COMPILER) &&                                        \
   !defined(CURL_DISABLE_DEPRECATION) && !defined(BUILDING_LIBCURL)
 #define CURL_DEPRECATED(version, message)                       \
   __attribute__((deprecated("since " # version ". " message)))
index 007de3c877c45d8d26028dec3362c3fd4456aaa0..935614c5fd043d51ad93416a11fc3e232fa9b3c9 100644 (file)
@@ -35,8 +35,7 @@ EXTRA_DIST = CMakeLists.txt
 
 AM_CPPFLAGS = -I$(top_srcdir)/include   \
               -I$(top_builddir)/lib     \
-              -I$(top_srcdir)/lib       \
-              -DCURL_DISABLE_DEPRECATION
+              -I$(top_srcdir)/lib
 
 LIBDIR = $(top_builddir)/lib
 
index d84b17643dd8b314693de56aa140dd870e6b957b..492548658a57fb15d7b69162e0cb8dd3f7bedd82 100644 (file)
@@ -477,7 +477,6 @@ lib1543_SOURCES = lib1518.c $(SUPPORTFILES)
 lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543
 
 lib1545_SOURCES = lib1545.c $(SUPPORTFILES)
-lib1545_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_DISABLE_DEPRECATION
 
 lib1550_SOURCES = lib1550.c $(SUPPORTFILES)
 
index c101b3eef2f5728450ac512bc54ae6dcfe30bdc6..a1891375b3e208669d3494d0bcee67e64bfbdd05 100644 (file)
@@ -21,9 +21,6 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#ifndef CURL_DISABLE_DEPRECATION
-#define CURL_DISABLE_DEPRECATION  /* Using and testing the form api */
-#endif
 #include "test.h"
 
 CURLcode test(char *URL)
@@ -38,17 +35,20 @@ CURLcode test(char *URL)
   easy_init(eh);
 
   easy_setopt(eh, CURLOPT_URL, URL);
-  curl_formadd(&m_formpost, &lastptr, CURLFORM_COPYNAME, "file",
-               CURLFORM_FILE, "missing-file", CURLFORM_END);
-  curl_easy_setopt(eh, CURLOPT_HTTPPOST, m_formpost);
+  CURL_IGNORE_DEPRECATION(
+    curl_formadd(&m_formpost, &lastptr, CURLFORM_COPYNAME, "file",
+                 CURLFORM_FILE, "missing-file", CURLFORM_END);
+    curl_easy_setopt(eh, CURLOPT_HTTPPOST, m_formpost);
+  )
 
   (void)curl_easy_perform(eh);
   (void)curl_easy_perform(eh);
 
 test_cleanup:
 
-  curl_formfree(m_formpost);
-
+  CURL_IGNORE_DEPRECATION(
+    curl_formfree(m_formpost);
+  )
   curl_easy_cleanup(eh);
   curl_global_cleanup();
 
index 0ec7ea2ef49b7732d792115ef292537935a55412..95fdf9eff343e7eafa94e2c0818b51633ec27db0 100644 (file)
@@ -21,7 +21,6 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_DISABLE_DEPRECATION  /* Using and testing the form api */
 #include "test.h"
 
 #include "memdebug.h"
@@ -76,23 +75,27 @@ static CURLcode once(char *URL, bool oldstyle)
 
   /* Fill in the file upload field */
   if(oldstyle) {
-    formrc = curl_formadd(&formpost,
-                          &lastptr,
-                          CURLFORM_COPYNAME, "sendfile",
-                          CURLFORM_STREAM, &pooh,
-                          CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
-                          CURLFORM_FILENAME, "postit2.c",
-                          CURLFORM_END);
+    CURL_IGNORE_DEPRECATION(
+      formrc = curl_formadd(&formpost,
+                            &lastptr,
+                            CURLFORM_COPYNAME, "sendfile",
+                            CURLFORM_STREAM, &pooh,
+                            CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
+                            CURLFORM_FILENAME, "postit2.c",
+                            CURLFORM_END);
+    )
   }
   else {
-    /* new style */
-    formrc = curl_formadd(&formpost,
-                          &lastptr,
-                          CURLFORM_COPYNAME, "sendfile alternative",
-                          CURLFORM_STREAM, &pooh,
-                          CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
-                          CURLFORM_FILENAME, "file name 2",
-                          CURLFORM_END);
+    CURL_IGNORE_DEPRECATION(
+      /* new style */
+      formrc = curl_formadd(&formpost,
+                            &lastptr,
+                            CURLFORM_COPYNAME, "sendfile alternative",
+                            CURLFORM_STREAM, &pooh,
+                            CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
+                            CURLFORM_FILENAME, "file name 2",
+                            CURLFORM_END);
+    )
   }
 
   if(formrc)
@@ -104,52 +107,58 @@ static CURLcode once(char *URL, bool oldstyle)
   pooh2.readptr = data;
   pooh2.sizeleft = strlen(data);
 
-  /* Fill in the file upload field */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "callbackdata",
-                        CURLFORM_STREAM, &pooh2,
-                        CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Fill in the file upload field */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "callbackdata",
+                          CURLFORM_STREAM, &pooh2,
+                          CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
+                          CURLFORM_END);
+  )
   if(formrc)
     printf("curl_formadd(2) = %d\n", (int)formrc);
 
-  /* Fill in the filename field */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "filename",
-                        CURLFORM_COPYCONTENTS, "postit2.c",
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Fill in the filename field */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "filename",
+                          CURLFORM_COPYCONTENTS, "postit2.c",
+                          CURLFORM_END);
+  )
   if(formrc)
     printf("curl_formadd(3) = %d\n", (int)formrc);
 
-  /* Fill in a submit field too */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "submit",
-                        CURLFORM_COPYCONTENTS, "send",
-                        CURLFORM_CONTENTTYPE, "text/plain",
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Fill in a submit field too */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "submit",
+                          CURLFORM_COPYCONTENTS, "send",
+                          CURLFORM_CONTENTTYPE, "text/plain",
+                          CURLFORM_END);
+  )
   if(formrc)
     printf("curl_formadd(4) = %d\n", (int)formrc);
 
-  formrc = curl_formadd(&formpost, &lastptr,
-                        CURLFORM_COPYNAME, "somename",
-                        CURLFORM_BUFFER, "somefile.txt",
-                        CURLFORM_BUFFERPTR, "blah blah",
-                        CURLFORM_BUFFERLENGTH, (long)9,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    formrc = curl_formadd(&formpost, &lastptr,
+                          CURLFORM_COPYNAME, "somename",
+                          CURLFORM_BUFFER, "somefile.txt",
+                          CURLFORM_BUFFERPTR, "blah blah",
+                          CURLFORM_BUFFERLENGTH, (long)9,
+                          CURLFORM_END);
+  )
   if(formrc)
     printf("curl_formadd(5) = %d\n", (int)formrc);
 
   curl = curl_easy_init();
   if(!curl) {
     fprintf(stderr, "curl_easy_init() failed\n");
-    curl_formfree(formpost);
+    CURL_IGNORE_DEPRECATION(
+      curl_formfree(formpost);
+    )
     curl_global_cleanup();
     return TEST_ERR_MAJOR_BAD;
   }
@@ -166,8 +175,10 @@ static CURLcode once(char *URL, bool oldstyle)
   /* we want to use our own read function */
   test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
 
-  /* send a multi-part formpost */
-  test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* send a multi-part formpost */
+    test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  )
 
   /* get verbose debug output please */
   test_setopt(curl, CURLOPT_VERBOSE, 1L);
@@ -180,11 +191,15 @@ static CURLcode once(char *URL, bool oldstyle)
 
 test_cleanup:
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+  CURL_IGNORE_DEPRECATION(
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  )
 
-  /* now cleanup the formpost chain */
-  curl_formfree(formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* now cleanup the formpost chain */
+    curl_formfree(formpost);
+  )
 
   return res;
 }
index 407641bb026830172a755dea1efdc87eb67e18db..2945e366f6bde5e4e10cb5cdc0f830a33f63e2d2 100644 (file)
@@ -21,7 +21,6 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_DISABLE_DEPRECATION  /* Using and testing the form api */
 #include "test.h"
 
 #include "memdebug.h"
@@ -80,12 +79,13 @@ CURLcode test(char *URL)
     goto test_cleanup;
   }
   headers = headers2;
-  formrc = curl_formadd(&formpost, &lastptr,
-                        CURLFORM_COPYNAME, &name,
-                        CURLFORM_COPYCONTENTS, &data,
-                        CURLFORM_CONTENTHEADER, headers,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    formrc = curl_formadd(&formpost, &lastptr,
+                          CURLFORM_COPYNAME, &name,
+                          CURLFORM_COPYCONTENTS, &data,
+                          CURLFORM_CONTENTHEADER, headers,
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(1) = %d\n", (int) formrc);
     goto test_cleanup;
@@ -93,21 +93,22 @@ CURLcode test(char *URL)
 
   contentlength = (long)(strlen(data) - 1);
 
-  /* Use a form array for the non-copy test. */
-  formarray[0].option = CURLFORM_PTRCONTENTS;
-  formarray[0].value = data;
-  formarray[1].option = CURLFORM_CONTENTSLENGTH;
-  formarray[1].value = (char *)(size_t)contentlength;
-  formarray[2].option = CURLFORM_END;
-  formarray[2].value = NULL;
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_PTRNAME, name,
-                        CURLFORM_NAMELENGTH, strlen(name) - 1,
-                        CURLFORM_ARRAY, formarray,
-                        CURLFORM_FILENAME, "remotefile.txt",
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Use a form array for the non-copy test. */
+    formarray[0].option = CURLFORM_PTRCONTENTS;
+    formarray[0].value = data;
+    formarray[1].option = CURLFORM_CONTENTSLENGTH;
+    formarray[1].value = (char *)(size_t)contentlength;
+    formarray[2].option = CURLFORM_END;
+    formarray[2].value = NULL;
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_PTRNAME, name,
+                          CURLFORM_NAMELENGTH, strlen(name) - 1,
+                          CURLFORM_ARRAY, formarray,
+                          CURLFORM_FILENAME, "remotefile.txt",
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(2) = %d\n", (int) formrc);
     goto test_cleanup;
@@ -118,57 +119,65 @@ CURLcode test(char *URL)
      CURLOPT_PTRNAME actually copies the name thus we do not test this here. */
   data[0]++;
 
-  /* Check multi-files and content type propagation. */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "multifile",
-                        CURLFORM_FILE, libtest_arg2,    /* Set in first.c. */
-                        CURLFORM_FILE, libtest_arg2,
-                        CURLFORM_CONTENTTYPE, "text/whatever",
-                        CURLFORM_FILE, libtest_arg2,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Check multi-files and content type propagation. */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "multifile",
+                          CURLFORM_FILE, libtest_arg2,    /* Set in first.c. */
+                          CURLFORM_FILE, libtest_arg2,
+                          CURLFORM_CONTENTTYPE, "text/whatever",
+                          CURLFORM_FILE, libtest_arg2,
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(3) = %d\n", (int) formrc);
     goto test_cleanup;
   }
 
-  /* Check data from file content. */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "filecontents",
-                        CURLFORM_FILECONTENT, libtest_arg2,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Check data from file content. */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "filecontents",
+                          CURLFORM_FILECONTENT, libtest_arg2,
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(4) = %d\n", (int) formrc);
     goto test_cleanup;
   }
 
-  /* Measure the current form length.
-   * This is done before including stdin data because we want to reuse it
-   * and stdin cannot be rewound.
-   */
-  curl_formget(formpost, (void *) &formlength, count_chars);
+  CURL_IGNORE_DEPRECATION(
+    /* Measure the current form length.
+     * This is done before including stdin data because we want to reuse it
+     * and stdin cannot be rewound.
+     */
+    curl_formget(formpost, (void *) &formlength, count_chars);
+  )
 
   /* Include length in data for external check. */
   curl_msnprintf(flbuf, sizeof(flbuf), "%lu", (unsigned long) formlength);
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "formlength",
-                        CURLFORM_COPYCONTENTS, &flbuf,
-                        CURLFORM_END);
+  CURL_IGNORE_DEPRECATION(
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "formlength",
+                          CURLFORM_COPYCONTENTS, &flbuf,
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(5) = %d\n", (int) formrc);
     goto test_cleanup;
   }
 
-  /* Check stdin (may be problematic on some platforms). */
-  formrc = curl_formadd(&formpost,
-                        &lastptr,
-                        CURLFORM_COPYNAME, "standardinput",
-                        CURLFORM_FILE, "-",
-                        CURLFORM_END);
+  CURL_IGNORE_DEPRECATION(
+    /* Check stdin (may be problematic on some platforms). */
+    formrc = curl_formadd(&formpost,
+                          &lastptr,
+                          CURLFORM_COPYNAME, "standardinput",
+                          CURLFORM_FILE, "-",
+                          CURLFORM_END);
+  )
   if(formrc) {
     printf("curl_formadd(6) = %d\n", (int) formrc);
     goto test_cleanup;
@@ -183,8 +192,10 @@ CURLcode test(char *URL)
   /* First set the URL that is about to receive our POST. */
   test_setopt(curl, CURLOPT_URL, URL);
 
-  /* send a multi-part formpost */
-  test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* send a multi-part formpost */
+    test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  )
 
   /* get verbose debug output please */
   test_setopt(curl, CURLOPT_VERBOSE, 1L);
@@ -203,8 +214,10 @@ test_cleanup:
   /* always cleanup */
   curl_easy_cleanup(curl);
 
-  /* now cleanup the formpost chain */
-  curl_formfree(formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* now cleanup the formpost chain */
+    curl_formfree(formpost);
+  )
   curl_slist_free_all(headers);
 
   curl_global_cleanup();
index c4754ee34c603432e6c83bb2620c120eaac281f7..3993dfa6222fefcce58a8d8d48b0de846e008ce6 100644 (file)
@@ -21,7 +21,6 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_DISABLE_DEPRECATION  /* Using and testing the form api */
 #include "test.h"
 
 #include "memdebug.h"
@@ -50,12 +49,13 @@ CURLcode test(char *URL)
     return TEST_ERR_MAJOR_BAD;
   }
 
-  /* Check proper name and data copying. */
-  formrc = curl_formadd(&formpost, &lastptr,
-                        CURLFORM_COPYNAME, "hello",
-                        CURLFORM_COPYCONTENTS, buffer,
-                        CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    /* Check proper name and data copying. */
+    formrc = curl_formadd(&formpost, &lastptr,
+                          CURLFORM_COPYNAME, "hello",
+                          CURLFORM_COPYCONTENTS, buffer,
+                          CURLFORM_END);
+  )
   if(formrc)
     printf("curl_formadd(1) = %d\n", (int) formrc);
 
@@ -63,7 +63,9 @@ CURLcode test(char *URL)
   curl = curl_easy_init();
   if(!curl) {
     fprintf(stderr, "curl_easy_init() failed\n");
-    curl_formfree(formpost);
+    CURL_IGNORE_DEPRECATION(
+      curl_formfree(formpost);
+    )
     curl_global_cleanup();
     return TEST_ERR_MAJOR_BAD;
   }
@@ -71,8 +73,10 @@ CURLcode test(char *URL)
   /* First set the URL that is about to receive our POST. */
   test_setopt(curl, CURLOPT_URL, URL);
 
-  /* send a multi-part formpost */
-  test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* send a multi-part formpost */
+    test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+  )
 
   /* get verbose debug output please */
   test_setopt(curl, CURLOPT_VERBOSE, 1L);
@@ -88,8 +92,10 @@ test_cleanup:
   /* always cleanup */
   curl_easy_cleanup(curl);
 
-  /* now cleanup the formpost chain */
-  curl_formfree(formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* now cleanup the formpost chain */
+    curl_formfree(formpost);
+  )
 
   curl_global_cleanup();
 
index fad3298e956c74aea342d4dd4506d308aba1c373..8c4a7b9651e864e4893dee30b081d8e7d6602766 100644 (file)
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-
-#if !defined(LIB670) && !defined(LIB671)
-#define CURL_DISABLE_DEPRECATION  /* Using and testing the form api */
-#endif
-
 #include "test.h"
 
 #include <time.h>
@@ -159,12 +154,14 @@ CURLcode test(char *URL)
   if(res == CURLE_OK)
     test_setopt(pooh.easy, CURLOPT_MIMEPOST, mime);
 #else
-  /* Build the form. */
-  formrc = curl_formadd(&formpost, &lastptr,
-                        CURLFORM_COPYNAME, name,
-                        CURLFORM_STREAM, &pooh,
-                        CURLFORM_CONTENTLEN, (curl_off_t) 2,
-                        CURLFORM_END);
+  CURL_IGNORE_DEPRECATION(
+    /* Build the form. */
+    formrc = curl_formadd(&formpost, &lastptr,
+                          CURLFORM_COPYNAME, name,
+                          CURLFORM_STREAM, &pooh,
+                          CURLFORM_CONTENTLEN, (curl_off_t) 2,
+                          CURLFORM_END);
+  )
   if(formrc) {
     fprintf(stderr, "curl_formadd() = %d\n", (int) formrc);
     goto test_cleanup;
@@ -173,8 +170,10 @@ CURLcode test(char *URL)
   /* We want to use our own read function. */
   test_setopt(pooh.easy, CURLOPT_READFUNCTION, read_callback);
 
-  /* Send a multi-part formpost. */
-  test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
+  CURL_IGNORE_DEPRECATION(
+    /* Send a multi-part formpost. */
+    test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
+  )
 #endif
 
 #if defined(LIB670) || defined(LIB672)
@@ -253,7 +252,9 @@ test_cleanup:
 #if defined(LIB670) || defined(LIB671)
   curl_mime_free(mime);
 #else
-  curl_formfree(formpost);
+  CURL_IGNORE_DEPRECATION(
+    curl_formfree(formpost);
+  )
 #endif
 
   curl_global_cleanup();
index 4b3921d77a2b857139d4cd7d289fb33edd010220..0eee841c2769c3ff2865c5d5f64a5bc13bc31dca 100755 (executable)
@@ -195,7 +195,6 @@ print <<HEADER
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_DISABLE_DEPRECATION  /* Deprecated options are tested too */
 #include "test.h"
 #include "memdebug.h"
 #include <limits.h>
@@ -352,6 +351,8 @@ CURLcode test(char *URL)
     res = CURLE_OUT_OF_MEMORY;
     goto test_cleanup;
   }
+
+  CURL_IGNORE_DEPRECATION(
 HEADER
     ;
 
@@ -584,6 +585,8 @@ MOO
 
 
 print <<FOOTER
+  )
+
   curl_easy_setopt(curl, (CURLoption)1, 0);
   res = CURLE_OK;
 test_cleanup:
index a782d5178aa63ee3113c9fe95a279043d2bd2a27..4d29fb887bc78a43a69a88a28fc98400229ae2cc 100644 (file)
@@ -21,7 +21,6 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#define CURL_DISABLE_DEPRECATION  /* Testing the form api */
 #include "curlcheck.h"
 
 #include <curl/curl.h>
@@ -51,49 +50,60 @@ UNITTEST_START
   size_t total_size = 0;
   char buffer[] = "test buffer";
 
-  rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
-                    CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
+                      CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
+  )
   fail_unless(rc == 0, "curl_formadd returned error");
 
   /* after the first curl_formadd when there's a single entry, both pointers
      should point to the same struct */
   fail_unless(post == last, "post and last weren't the same");
 
-  rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
-                    CURLFORM_COPYCONTENTS, "<HTML></HTML>",
-                    CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
+                      CURLFORM_COPYCONTENTS, "<HTML></HTML>",
+                      CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
+  )
   fail_unless(rc == 0, "curl_formadd returned error");
 
-  rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
-                   CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
+                     CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
+  )
   fail_unless(rc == 0, "curl_formadd returned error");
 
-  res = curl_formget(post, &total_size, print_httppost_callback);
-
+  CURL_IGNORE_DEPRECATION(
+    res = curl_formget(post, &total_size, print_httppost_callback);
+  )
   fail_unless(res == 0, "curl_formget returned error");
 
   fail_unless(total_size == 518, "curl_formget got wrong size back");
 
-  curl_formfree(post);
+  CURL_IGNORE_DEPRECATION(
+    curl_formfree(post);
+  )
 
   /* start a new formpost with a file upload and formget */
   post = last = NULL;
 
-  rc = curl_formadd(&post, &last,
-                    CURLFORM_PTRNAME, "name of file field",
-                    CURLFORM_FILE, arg,
-                    CURLFORM_FILENAME, "custom named file",
-                    CURLFORM_END);
-
+  CURL_IGNORE_DEPRECATION(
+    rc = curl_formadd(&post, &last,
+                      CURLFORM_PTRNAME, "name of file field",
+                      CURLFORM_FILE, arg,
+                      CURLFORM_FILENAME, "custom named file",
+                      CURLFORM_END);
+  )
   fail_unless(rc == 0, "curl_formadd returned error");
 
-  res = curl_formget(post, &total_size, print_httppost_callback);
+  CURL_IGNORE_DEPRECATION(
+    res = curl_formget(post, &total_size, print_httppost_callback);
+  )
   fail_unless(res == 0, "curl_formget returned error");
   fail_unless(total_size == 899, "curl_formget got wrong size back");
 
-  curl_formfree(post);
+  CURL_IGNORE_DEPRECATION(
+    curl_formfree(post);
+  )
 
 UNITTEST_STOP