From: Francesco Chemolli Date: Wed, 11 Sep 2013 00:58:09 +0000 (-0600) Subject: Improved compatibility with clang and icc X-Git-Tag: SQUID_3_3_10~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0b1155dac551d6343eaad0d0ed9f4fb39fec30b;p=thirdparty%2Fsquid.git Improved compatibility with clang and icc --- diff --git a/acinclude/compiler-flags.m4 b/acinclude/compiler-flags.m4 index 345c2dea05..6ece7d7945 100644 --- a/acinclude/compiler-flags.m4 +++ b/acinclude/compiler-flags.m4 @@ -170,8 +170,8 @@ AC_DEFUN([SQUID_CC_GUESS_OPTIONS], [ squid_cv_cc_arg_pipe="" ;; clang) - squid_cv_cxx_option_werror="-Werror -Wno-error=parentheses-equality" - squid_cv_cc_option_werror="$squid_cv_cxx_option_werror" + squid_cv_cxx_option_werror="-Werror -Qunused-arguments" + squid_cv_cc_option_werror="$squid_cv_cxx_option_werror" squid_cv_cc_option_wall="-Wall" squid_cv_cc_option_optimize="-O2" squid_cv_cc_arg_pipe="" diff --git a/compat/GnuRegex.c b/compat/GnuRegex.c index 3285f687ea..0dac6063a7 100644 --- a/compat/GnuRegex.c +++ b/compat/GnuRegex.c @@ -90,8 +90,6 @@ init_syntax_once(void) #endif /* not SYNTAX_TABLE */ -#define SYNTAX(c) re_syntax_table[c] - /* Get the interface, including the syntax bits. */ #include "compat/GnuRegex.h" @@ -889,9 +887,6 @@ static reg_errcode_t compile_range(const char **p_ptr, const char *pend, char *t #define INIT_COMPILE_STACK_SIZE 32 -#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) -#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) - /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) @@ -1420,7 +1415,7 @@ handle_open: bufp->re_nsub++; regnum++; - if (COMPILE_STACK_FULL) { + if (compile_stack.avail == compile_stack.size) { RETALLOC(compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); if (compile_stack.stack == NULL) @@ -1461,7 +1456,7 @@ handle_open: if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - if (COMPILE_STACK_EMPTY) { + if (compile_stack.avail == 0) { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else @@ -1479,7 +1474,7 @@ handle_close: STORE_JUMP(jump_past_alt, fixup_alt_jump, b - 1); } /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) { + if (compile_stack.avail == 0) { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else @@ -1832,7 +1827,7 @@ normal_char: if (fixup_alt_jump) STORE_JUMP(jump_past_alt, fixup_alt_jump, b); - if (!COMPILE_STACK_EMPTY) + if (compile_stack.avail != 0) return REG_EPAREN; free(compile_stack.stack); @@ -2374,13 +2369,13 @@ struct re_pattern_buffer *bufp; case wordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX(j) == Sword) + if (re_syntax_table[j] == Sword) fastmap[j] = 1; break; case notwordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX(j) != Sword) + if (re_syntax_table[j] != Sword) fastmap[j] = 1; break; @@ -2732,21 +2727,31 @@ static boolean group_match_null_string_p(unsigned char **p, unsigned char *end, /* Test if at very beginning or at very end of the virtual concatenation * of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END(d) ((d) == end2) +static int at_strings_end(const char *d, const char *end2) +{ + return d == end2; +} /* Test if D points to a character which is word-constituent. We have * two special cases to check for: if past the end of string1, look at * the first character in string2; and if before the beginning of * string2, look at the last character in string1. */ #define WORDCHAR_P(d) \ - (SYNTAX ((d) == end1 ? *string2 \ - : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ + (re_syntax_table[(d) == end1 ? *string2 \ + : (d) == string2 - 1 ? *(end1 - 1) : *(d)] \ == Sword) +static int +wordchar_p(const char *d, const char *end1, const char *string2) +{ + return re_syntax_table[(d) == end1 ? *string2 + : (d) == string2 - 1 ? *(end1 - 1) : *(d)] + == Sword; +} /* Test if the character before D and the one at D differ with respect * to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ + (AT_STRINGS_BEG (d) || at_strings_end(d,end2) \ || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) /* Free everything we malloc. */ @@ -3440,7 +3445,7 @@ restore_best_regs: case endline: DEBUG_PRINT1("EXECUTING endline.\n"); - if (AT_STRINGS_END(d)) { + if (at_strings_end(d,end2)) { if (!bufp->not_eol) break; } @@ -3461,7 +3466,7 @@ restore_best_regs: /* Match at the very end of the data. */ case endbuf: DEBUG_PRINT1("EXECUTING endbuf.\n"); - if (AT_STRINGS_END(d)) + if (at_strings_end(d,end2)) break; goto fail; @@ -3739,21 +3744,21 @@ unconditional_jump: case wordbeg: DEBUG_PRINT1("EXECUTING wordbeg.\n"); - if (WORDCHAR_P(d) && (AT_STRINGS_BEG(d) || !WORDCHAR_P(d - 1))) + if (wordchar_p(d,end1,string2) && (AT_STRINGS_BEG(d) || !WORDCHAR_P(d - 1))) break; goto fail; case wordend: DEBUG_PRINT1("EXECUTING wordend.\n"); if (!AT_STRINGS_BEG(d) && WORDCHAR_P(d - 1) - && (!WORDCHAR_P(d) || AT_STRINGS_END(d))) + && (!wordchar_p(d,end1,string2) || at_strings_end(d,end2))) break; goto fail; case wordchar: DEBUG_PRINT1("EXECUTING non-Emacs wordchar.\n"); PREFETCH(); - if (!WORDCHAR_P(d)) + if (!wordchar_p(d,end1,string2)) goto fail; SET_REGS_MATCHED(); d++; @@ -3762,7 +3767,7 @@ unconditional_jump: case notwordchar: DEBUG_PRINT1("EXECUTING non-Emacs notwordchar.\n"); PREFETCH(); - if (WORDCHAR_P(d)) + if (wordchar_p(d,end1,string2)) goto fail; SET_REGS_MATCHED(); d++; diff --git a/lib/rfcnb/session.c b/lib/rfcnb/session.c index 4aaf11b764..b2d4246ea5 100644 --- a/lib/rfcnb/session.c +++ b/lib/rfcnb/session.c @@ -84,7 +84,7 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port /* Resolve that name into an IP address */ Service_Address = Called_Name; - if (strcmp(Called_Address, "") != 0) { /* If the Called Address = "" */ + if (strlen(Called_Address) != 0) { /* If the Called Address = "" */ Service_Address = Called_Address; } if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ diff --git a/lib/smblib/smblib.c b/lib/smblib/smblib.c index 79de3d6143..7eade4fc6c 100644 --- a/lib/smblib/smblib.c +++ b/lib/smblib/smblib.c @@ -152,7 +152,7 @@ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, calling[strlen(con -> myname)] = 0; /* Make it a string */ - if (strcmp(con -> address, "") == 0) + if (strlen(con -> address) == 0) address = con -> desthost; else address = con -> address; @@ -268,7 +268,7 @@ SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle, calling[strlen(con -> myname)] = 0; /* Make it a string */ - if (strcmp(con -> address, "") == 0) + if (strlen(con -> address) == 0) address = con -> desthost; else address = con -> address; diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc index 9a89187100..c6f8d253a5 100644 --- a/src/ssl/gadgets.cc +++ b/src/ssl/gadgets.cc @@ -410,7 +410,7 @@ static BIGNUM *createCertSerial(unsigned char *md, unsigned int n) serial = BN_bin2bn(md, n, NULL); // if the serial is "0" set it to '1' - if (BN_is_zero(serial)) + if (BN_is_zero(serial) == true) BN_one(serial); // serial size does not exceed 20 bytes diff --git a/tools/purge/conffile.cc b/tools/purge/conffile.cc index 8a17e7a9e7..8d3fb62bd1 100644 --- a/tools/purge/conffile.cc +++ b/tools/purge/conffile.cc @@ -34,10 +34,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "conffile.hh" #include #include diff --git a/tools/purge/conffile.hh b/tools/purge/conffile.hh index 960fd8ec63..a37ae88d4f 100644 --- a/tools/purge/conffile.hh +++ b/tools/purge/conffile.hh @@ -39,16 +39,12 @@ #define _CONFFILE_HH #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL typedef int bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ diff --git a/tools/purge/convert.cc b/tools/purge/convert.cc index 64e8ec1415..2d0df6fc5f 100644 --- a/tools/purge/convert.cc +++ b/tools/purge/convert.cc @@ -40,9 +40,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif #include "convert.hh" #include diff --git a/tools/purge/convert.hh b/tools/purge/convert.hh index c842724020..5cd39b7454 100644 --- a/tools/purge/convert.hh +++ b/tools/purge/convert.hh @@ -39,16 +39,12 @@ #define _CONVERT_HH #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL 1 typedef char bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ #include diff --git a/tools/purge/copyout.cc b/tools/purge/copyout.cc index 872c816580..f57554ef24 100644 --- a/tools/purge/copyout.cc +++ b/tools/purge/copyout.cc @@ -35,10 +35,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "squid.h" #include "copyout.hh" diff --git a/tools/purge/copyout.hh b/tools/purge/copyout.hh index f39907e0c4..5440490900 100644 --- a/tools/purge/copyout.hh +++ b/tools/purge/copyout.hh @@ -35,16 +35,12 @@ #define _COPYOUT_HH #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL typedef int bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ int diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc index 4e65720e56..6f91f8e200 100644 --- a/tools/purge/purge.cc +++ b/tools/purge/purge.cc @@ -90,10 +90,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "squid.h" #include "util.h" diff --git a/tools/purge/signal.cc b/tools/purge/signal.cc index 213353f44e..4f6906c2eb 100644 --- a/tools/purge/signal.cc +++ b/tools/purge/signal.cc @@ -41,11 +41,6 @@ // Initial revision // // - -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "squid.h" #include "signal.hh" diff --git a/tools/purge/signal.hh b/tools/purge/signal.hh index 19d9e5749b..1e021cbfe7 100644 --- a/tools/purge/signal.hh +++ b/tools/purge/signal.hh @@ -55,16 +55,12 @@ #endif #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL typedef int bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ #if 1 // so far, all systems I know use void diff --git a/tools/purge/socket.cc b/tools/purge/socket.cc index d8884f10b8..27d8b3b481 100644 --- a/tools/purge/socket.cc +++ b/tools/purge/socket.cc @@ -42,10 +42,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "socket.hh" #include #include diff --git a/tools/purge/socket.hh b/tools/purge/socket.hh index 22679c711f..c1631bc74f 100644 --- a/tools/purge/socket.hh +++ b/tools/purge/socket.hh @@ -45,16 +45,12 @@ #define _SOCKET_HH #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL typedef int bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ #include diff --git a/tools/purge/squid-tlv.cc b/tools/purge/squid-tlv.cc index e3fc2105d2..7225f11a53 100644 --- a/tools/purge/squid-tlv.cc +++ b/tools/purge/squid-tlv.cc @@ -32,10 +32,6 @@ // Initial revision // // -#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) -#pragma implementation -#endif - #include "squid.h" //#include #include "squid-tlv.hh" diff --git a/tools/purge/squid-tlv.hh b/tools/purge/squid-tlv.hh index 5be4056af5..fdaec97ffd 100644 --- a/tools/purge/squid-tlv.hh +++ b/tools/purge/squid-tlv.hh @@ -35,16 +35,12 @@ #define SQUID_TLV_HH #if !defined(__cplusplus) -#if defined(__GNUC__) || defined(__GNUG__) -#pragma interface -#else #ifndef HAVE_BOOL #define HAVE_BOOL typedef int bool; #define false 0 #define true 1 #endif -#endif #endif /* __cplusplus */ #include