1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

lib: include curl_printf.h as one of the last headers

curl_printf.h defines printf to curl_mprintf, etc. This can cause
problems with external headers which may use
__attribute__((format(printf, ...))) markers etc.

To avoid that they cause problems with system includes, we include
curl_printf.h after any system headers. That makes the three last
headers to always be, and we keep them in this order:

 curl_printf.h
 curl_memory.h
 memdebug.h

None of them include system headers, they all do funny #defines.

Reported-by: David Benjamin

Fixes #743
This commit is contained in:
Daniel Stenberg 2016-04-29 15:46:40 +02:00
parent 63b5378a61
commit 4f45240bc8
49 changed files with 90 additions and 103 deletions

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -68,7 +68,6 @@
#include "connect.h"
#include "select.h"
#include "progress.h"
#include "curl_printf.h"
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
@ -83,8 +82,9 @@
#define HAVE_CARES_CALLBACK_TIMEOUTS 1
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
struct ResolverResults {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -69,10 +69,9 @@
#include "inet_ntop.h"
#include "curl_threads.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/***********************************************************************

View File

@ -23,13 +23,13 @@
/* Base64 encoding/decoding */
#include "curl_setup.h"
#include "curl_printf.h"
#include "urldata.h" /* for the SessionHandle definition */
#include "warnless.h"
#include "curl_base64.h"
#include "non-ascii.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012, Linus Nielsen Feltzing, <linus@haxx.se>
* Copyright (C) 2012, 2016, Linus Nielsen Feltzing, <linus@haxx.se>
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
@ -32,10 +32,9 @@
#include "sendf.h"
#include "rawstr.h"
#include "conncache.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
static void conn_llist_dtor(void *user, void *element)

View File

@ -56,7 +56,6 @@
#include <inet.h>
#endif
#include "curl_printf.h"
#include "urldata.h"
#include "sendf.h"
#include "if2ip.h"
@ -74,7 +73,8 @@
#include "conncache.h"
#include "multihandle.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -88,7 +88,6 @@ Example set of cookies:
# include <libpsl.h>
#endif
#include "curl_printf.h"
#include "urldata.h"
#include "cookie.h"
#include "strequal.h"
@ -101,7 +100,8 @@ Example set of cookies:
#include "curl_memrchr.h"
#include "inet_pton.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -50,10 +50,9 @@
#include "curl_addrinfo.h"
#include "inet_pton.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/*

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -107,9 +107,8 @@
#include "warnless.h"
#include "curl_endian.h"
#include "curl_des.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -51,9 +51,8 @@
#include "curl_ntlm_wb.h"
#include "url.h"
#include "strerror.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -46,9 +46,8 @@
#include "rawstr.h"
#include "sendf.h"
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -73,9 +73,8 @@
#include "multiif.h"
#include "sigpipe.h"
#include "ssh.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -31,9 +31,8 @@
#include "warnless.h"
#include "non-ascii.h"
#include "escape.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -61,9 +61,8 @@
#include "url.h"
#include "parsedate.h" /* for the week day and month names */
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -36,9 +36,8 @@
#include "strequal.h"
#include "sendf.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -77,10 +77,9 @@
#include "warnless.h"
#include "http_proxy.h"
#include "non-ascii.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
#ifndef NI_MAXHOST

View File

@ -56,9 +56,9 @@
#include "url.h"
#include "inet_ntop.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
#if defined(CURLRES_SYNCH) && \

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -48,9 +48,9 @@
#include "strerror.h"
#include "url.h"
#include "inet_pton.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/***********************************************************************

View File

@ -49,10 +49,9 @@
#include "url.h"
#include "inet_pton.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/***********************************************************************

View File

@ -77,9 +77,9 @@
#include "pipeline.h"
#include "http2.h"
#include "connect.h"
#include "curl_printf.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -23,7 +23,6 @@
#include "curl_setup.h"
#ifdef USE_NGHTTP2
#include "curl_printf.h"
#include <nghttp2/nghttp2.h>
#include "urldata.h"
#include "http2.h"
@ -37,7 +36,8 @@
#include "connect.h"
#include "strtoofft.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -28,9 +28,8 @@
#include "rawstr.h"
#include "vauth/vauth.h"
#include "http_digest.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -29,9 +29,9 @@
#include "rawstr.h"
#include "http_negotiate.h"
#include "vauth/vauth.h"
#include "curl_printf.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -40,7 +40,6 @@
#include "curl_ntlm_wb.h"
#include "vauth/vauth.h"
#include "url.h"
#include "curl_printf.h"
#if defined(USE_NSS)
#include "vtls/nssg.h"
@ -48,7 +47,8 @@
#include "curl_sspi.h"
#endif
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -35,11 +35,11 @@
#include "progress.h"
#include "non-ascii.h"
#include "connect.h"
#include "curl_printf.h"
#include "curlx.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
CURLcode Curl_proxy_connect(struct connectdata *conn)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -53,10 +53,9 @@
#include "inet_ntop.h"
#include "strequal.h"
#include "if2ip.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* ------------------------------------------------------------------ */

View File

@ -80,10 +80,10 @@
#include "rawstr.h"
#include "curl_sasl.h"
#include "warnless.h"
#include "curl_printf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* Local API functions */

View File

@ -32,9 +32,8 @@
#include <arpa/inet.h>
#endif
#include "curl_printf.h"
#include "inet_ntop.h"
#include "curl_printf.h"
#define IN6ADDRSZ 16
#define INADDRSZ 4
@ -57,10 +56,10 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
tmp[0] = '\0';
(void)snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
((int)((unsigned char)src[0])) & 0xff,
((int)((unsigned char)src[1])) & 0xff,
((int)((unsigned char)src[2])) & 0xff,
((int)((unsigned char)src[3])) & 0xff);
((int)((unsigned char)src[0])) & 0xff,
((int)((unsigned char)src[1])) & 0xff,
((int)((unsigned char)src[2])) & 0xff,
((int)((unsigned char)src[3])) & 0xff);
len = strlen(tmp);
if(len == 0 || len >= size) {

View File

@ -47,9 +47,9 @@
#include "sendf.h"
#include "curl_sec.h"
#include "warnless.h"
#include "curl_printf.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -76,9 +76,8 @@
#include "curl_base64.h"
#include "rawstr.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -26,10 +26,12 @@
#include <curl/curl.h>
#include "curl_printf.h"
#include "urldata.h"
#define MEMDEBUG_NODEFINES /* don't redefine the standard functions */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -42,9 +42,9 @@
#include "multihandle.h"
#include "pipeline.h"
#include "sigpipe.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/*

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -32,9 +32,9 @@
#include "strequal.h"
#include "strtok.h"
#include "rawstr.h"
#include "curl_printf.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
* Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2011 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -46,9 +46,8 @@
#include "curl_ldap.h"
#include "curl_base64.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -34,10 +34,10 @@
#include "multiif.h"
#include "non-ascii.h"
#include "vtls/vtls.h"
#include "curl_printf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
#ifdef USE_PINGPONG

View File

@ -83,9 +83,9 @@
#include "curl_sasl.h"
#include "curl_md5.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* Local API functions */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -36,9 +36,8 @@
#include "rawstr.h"
#include "select.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -31,11 +31,11 @@
#include "ssh.h"
#include "multiif.h"
#include "non-ascii.h"
#include "curl_printf.h"
#include "strerror.h"
#include "select.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -82,9 +82,9 @@
#include "curl_gethostname.h"
#include "curl_sasl.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* Local API functions */

View File

@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -32,9 +32,10 @@
#include "timeval.h"
#include "socks.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
static gss_ctx_id_t gss_context = GSS_C_NO_CONTEXT;

View File

@ -34,9 +34,9 @@
#include "curl_sspi.h"
#include "curl_multibyte.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/*

View File

@ -83,9 +83,10 @@
#include "multiif.h"
#include "select.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
#ifdef WIN32

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2004 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2004 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -44,9 +44,9 @@
#endif
#include "strerror.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
const char *

View File

@ -51,7 +51,6 @@
#include "telnet.h"
#include "connect.h"
#include "progress.h"
#include "curl_printf.h"
#define TELOPTS
#define TELCMDS
@ -62,7 +61,8 @@
#include "rawstr.h"
#include "warnless.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -57,10 +57,10 @@
#include "url.h"
#include "rawstr.h"
#include "speedcheck.h"
#include "curl_printf.h"
#include "select.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -75,9 +75,9 @@
#include "multiif.h"
#include "connect.h"
#include "non-ascii.h"
#include "curl_printf.h"
/* The last #include files should be: */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"

View File

@ -130,9 +130,9 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "pipeline.h"
#include "dotdot.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/* Local static prototypes */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -25,9 +25,9 @@
#include "wildcard.h"
#include "llist.h"
#include "fileinfo.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
CURLcode Curl_wildcard_init(struct WildcardData *wc)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -34,9 +34,10 @@
#include "inet_pton.h"
#include "curl_base64.h"
#include "x509asn1.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -20,7 +20,7 @@
*
***************************************************************************/
#include "curl_setup.h"
#include <curl/curl.h>
#include "testutil.h"
#include "memdebug.h"