mirror of
https://github.com/curl/curl.git
synced 2026-08-24 14:03:35 +03:00
build: fix compiling with GCC 4.x versions
- silence false positive picky warnings. - avoid "possible noreturn" warnings for standalone tests and examples. - fix to compile without `#pragma GCC diagnostic push` support. - fix "#pragma GCC diagnostic not allowed inside functions". Prerequisite for #15975 that needs GCC 4.4 for the latest pre-built CeGCC/mingw32ce toolchain for Windows CE. Cherry-picked from #15975 Closes #16062
This commit is contained in:
parent
96843f4ef7
commit
7e814c8717
13 changed files with 91 additions and 65 deletions
|
|
@ -31,6 +31,10 @@
|
|||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||
#endif
|
||||
|
||||
static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
|
|
@ -41,11 +45,6 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
|
|||
{
|
||||
CURLcode rv = CURLE_ABORTED_BY_CALLBACK;
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||
#endif
|
||||
|
||||
/** This example uses two (fake) certificates **/
|
||||
static const char mypem[] =
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
|
|
@ -90,10 +89,6 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
|
|||
"Z05phkOTOPu220+DkdRgfks+KzgHVZhepA==\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem));
|
||||
X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,19 @@
|
|||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* Avoid warning in FD_SET() with pre-2020 Cygwin/MSYS releases:
|
||||
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'}
|
||||
* may change the sign of the result [-Wsign-conversion]
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#ifdef __DJGPP__
|
||||
#pragma GCC diagnostic ignored "-Warith-conversion"
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#endif
|
||||
|
||||
/* Auxiliary function that waits on the socket. */
|
||||
static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
|
||||
{
|
||||
|
|
@ -49,20 +62,6 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
|
|||
FD_ZERO(&outfd);
|
||||
FD_ZERO(&errfd);
|
||||
|
||||
/* Avoid this warning with pre-2020 Cygwin/MSYS releases:
|
||||
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'}
|
||||
* may change the sign of the result [-Wsign-conversion]
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#if defined(__DJGPP__)
|
||||
#pragma GCC diagnostic ignored "-Warith-conversion"
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#endif
|
||||
FD_SET(sockfd, &errfd); /* always check for error */
|
||||
|
||||
if(for_recv) {
|
||||
|
|
@ -71,11 +70,6 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
|
|||
else {
|
||||
FD_SET(sockfd, &outfd);
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/* select() returns the number of signalled sockets or -1 */
|
||||
res = select((int)sockfd + 1, &infd, &outfd, &errfd, &tv);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@
|
|||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||
#endif
|
||||
|
||||
static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
fwrite(ptr, size, nmemb, stream);
|
||||
|
|
@ -55,11 +59,6 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
|
|||
RSA *rsa = NULL;
|
||||
int ret;
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||
#endif
|
||||
|
||||
const char *mypem = /* www.cacert.org */
|
||||
"-----BEGIN CERTIFICATE-----\n"\
|
||||
"MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\n"\
|
||||
|
|
@ -124,10 +123,6 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
|
|||
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"\
|
||||
"-----END RSA PRIVATE KEY-----\n";
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
(void)curl; /* avoid warnings */
|
||||
(void)parm; /* avoid warnings */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue