mirror of
https://github.com/curl/curl.git
synced 2026-07-28 09:13:07 +03:00
build: tidy up deprecation suppression, enable warnings for clang
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 to5fc61a37c1#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 to0f10360073#12444 - libtest, unit: replace `CURL_DISABLE_DEPRECATION` with `CURL_IGNORE_DEPRECATION()`. - docs/examples: replace pragmas with `CURL_IGNORE_DEPRECATION()`. Closes #14789
This commit is contained in:
parent
e1ab01d1bd
commit
5cefda1b93
13 changed files with 280 additions and 239 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@
|
|||
|
||||
#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);
|
||||
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 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);
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@
|
|||
|
||||
#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);
|
||||
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 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);
|
||||
/* 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue