From: Amos Jeffries Date: Sun, 30 Oct 2011 02:42:27 +0000 (+1300) Subject: Source Maintenance: Optimizations and macro fixes X-Git-Tag: BumpSslServerFirst.take01~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=605f2c3ee96a62585efb7c59850b04be9c17e1ac;p=thirdparty%2Fsquid.git Source Maintenance: Optimizations and macro fixes * optimize the maintenance script to ony scan for macro problems once * fix some file macro wrappers not to clash with the OS-macro naming scheme * fix macro ifdef/ifndef on feature presence macros to use defined() instead --- diff --git a/compat/strnstr.cc b/compat/strnstr.cc index 3c86e170c0..7c2f058ded 100644 --- a/compat/strnstr.cc +++ b/compat/strnstr.cc @@ -1,5 +1,5 @@ -#ifndef _SQUID_COMPAT_STRNSTR_CC_ -#define _SQUID_COMPAT_STRNSTR_CC_ +#ifndef SQUID_COMPAT_STRNSTR_CC_ +#define SQUID_COMPAT_STRNSTR_CC_ /* * Shamelessly duplicated from the FreeBSD public sources @@ -93,4 +93,4 @@ squid_strnstr(const char *s, const char *find, size_t slen) } #endif /* !HAVE_STRNSTR */ -#endif /* _SQUID_COMPAT_STRNSTR_CC_ */ +#endif /* SQUID_COMPAT_STRNSTR_CC_ */ diff --git a/compat/xstring.h b/compat/xstring.h index c5248bda8a..0b825d215f 100644 --- a/compat/xstring.h +++ b/compat/xstring.h @@ -1,5 +1,5 @@ -#ifndef _SQUID_COMPAT_XSTRING_H -#define _SQUID_COMPAT_XSTRING_H +#ifndef SQUID_COMPAT_XSTRING_H +#define SQUID_COMPAT_XSTRING_H #if HAVE_STRING_H #include @@ -54,4 +54,4 @@ extern "C" { } #endif -#endif /* _SQUID_COMPAT_XSTRING_H */ +#endif /* SQUID_COMPAT_XSTRING_H */ diff --git a/compat/xstrto.cc b/compat/xstrto.cc index 20bdeddab8..1e83e05fb2 100644 --- a/compat/xstrto.cc +++ b/compat/xstrto.cc @@ -1,5 +1,5 @@ -#ifndef _SQUID_XSTRTO_C_ -#define _SQUID_XSTRTO_C_ +#ifndef SQUID_XSTRTO_C_ +#define SQUID_XSTRTO_C_ /* * Shamelessly duplicated from the netfilter iptables sources @@ -92,4 +92,4 @@ xstrtoui(const char *s, char **end, unsigned int *value, return ret; } -#endif /* _SQUID_XSTRTO_C_ */ +#endif /* SQUID_XSTRTO_C_ */ diff --git a/helpers/basic_auth/PAM/basic_pam_auth.cc b/helpers/basic_auth/PAM/basic_pam_auth.cc index 6a103c58f7..3f8f0eee1c 100644 --- a/helpers/basic_auth/PAM/basic_pam_auth.cc +++ b/helpers/basic_auth/PAM/basic_pam_auth.cc @@ -93,12 +93,12 @@ #endif /* The default PAM service name */ -#ifndef DEFAULT_SQUID_PAM_SERVICE +#if !defined(DEFAULT_SQUID_PAM_SERVICE) #define DEFAULT_SQUID_PAM_SERVICE "squid" #endif /* The default TTL */ -#ifndef DEFAULT_SQUID_PAM_TTL +#if !defined(DEFAULT_SQUID_PAM_TTL) #define DEFAULT_SQUID_PAM_TTL 0 #endif diff --git a/helpers/digest_auth/LDAP/digest_common.h b/helpers/digest_auth/LDAP/digest_common.h index 3f6fba38bf..039108e76c 100644 --- a/helpers/digest_auth/LDAP/digest_common.h +++ b/helpers/digest_auth/LDAP/digest_common.h @@ -8,8 +8,8 @@ * Copyright (c) 2003 Robert Collins */ -#ifndef _SQUID_DIGEST_COMMON_H_ -#define _SQUID_DIGEST_COMMON_H_ +#ifndef SQUID_DIGEST_COMMON_H_ +#define SQUID_DIGEST_COMMON_H_ #if HAVE_STDIO_H #include @@ -56,4 +56,5 @@ typedef struct _request_data { */ typedef void HandleArguments(int, char **); typedef void HHA1Creator(RequestData *); -#endif /* _SQUID_DIGEST_COMMON_H_ */ + +#endif /* SQUID_DIGEST_COMMON_H_ */ diff --git a/helpers/digest_auth/eDirectory/digest_common.h b/helpers/digest_auth/eDirectory/digest_common.h index d403c2c3e0..6f1bb672e1 100644 --- a/helpers/digest_auth/eDirectory/digest_common.h +++ b/helpers/digest_auth/eDirectory/digest_common.h @@ -8,8 +8,8 @@ * Copyright (c) 2003 Robert Collins */ -#ifndef _SQUID_DIGEST_COMMON_H_ -#define _SQUID_DIGEST_COMMON_H_ +#ifndef SQUID_DIGEST_COMMON_H_ +#define SQUID_DIGEST_COMMON_H_ #if HAVE_STDIO_H #include @@ -59,4 +59,5 @@ typedef struct _request_data { */ typedef void HandleArguments(int, char **); typedef void HHA1Creator(RequestData *); -#endif /* _SQUID_DIGEST_COMMON_H_ */ + +#endif /* SQUID_DIGEST_COMMON_H_ */ diff --git a/helpers/digest_auth/file/digest_common.h b/helpers/digest_auth/file/digest_common.h index 5c26bca6db..f7dfaa8e6b 100644 --- a/helpers/digest_auth/file/digest_common.h +++ b/helpers/digest_auth/file/digest_common.h @@ -8,8 +8,8 @@ * Copyright (c) 2003 Robert Collins */ -#ifndef _SQUID_DIGEST_COMMON_H_ -#define _SQUID_DIGEST_COMMON_H_ +#ifndef SQUID_DIGEST_COMMON_H_ +#define SQUID_DIGEST_COMMON_H_ #include "hash.h" #include "rfc2617.h" @@ -47,4 +47,5 @@ typedef struct _request_data { */ typedef void HandleArguments(int, char **); typedef void HHA1Creator(RequestData *); -#endif /* _SQUID_DIGEST_COMMON_H_ */ + +#endif /* SQUID_DIGEST_COMMON_H_ */ diff --git a/include/RefCount.h b/include/RefCount.h index 77ba37cac1..8ddb9d240f 100644 --- a/include/RefCount.h +++ b/include/RefCount.h @@ -32,8 +32,8 @@ * */ -#ifndef _SQUID_REFCOUNT_H_ -#define _SQUID_REFCOUNT_H_ +#ifndef SQUID_REFCOUNT_H_ +#define SQUID_REFCOUNT_H_ #if HAVE_IOSTREAM #include @@ -144,4 +144,4 @@ inline std::ostream &operator <<(std::ostream &os, const RefCount &p) return os << "NULL"; } -#endif /* _SQUID_REFCOUNT_H_ */ +#endif /* SQUID_REFCOUNT_H_ */ diff --git a/include/util.h b/include/util.h index 18e62e7d40..4bcd24e0b4 100644 --- a/include/util.h +++ b/include/util.h @@ -48,7 +48,7 @@ SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval); SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval); SQUIDCEXTERN size_t xcountws(const char *str); SQUIDCEXTERN void Tolower(char *); -#ifdef __cplusplus +#if defined(__cplusplus) /* * Any code using libstdc++ must have externally resolvable overloads * for void * operator new - which means in the .o for the binary, @@ -56,8 +56,8 @@ SQUIDCEXTERN void Tolower(char *); * so, look in the translation unit containing main() in squid * for the extern version in squid */ -#ifndef _SQUID_EXTERNNEW_ -#ifdef __GNUC_STDC_INLINE__ +#if !defined(_SQUID_EXTERNNEW_) +#if defined(__GNUC_STDC_INLINE__) #define _SQUID_EXTERNNEW_ extern inline __attribute__((gnu_inline)) #else #define _SQUID_EXTERNNEW_ extern inline diff --git a/lib/ntlmauth/support_bits.cci b/lib/ntlmauth/support_bits.cci index 06083ca22d..a13c5e9771 100644 --- a/lib/ntlmauth/support_bits.cci +++ b/lib/ntlmauth/support_bits.cci @@ -1,5 +1,5 @@ -#ifndef _SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI -#define _SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI +#ifndef SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI +#define SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI #if HAVE_STRING_H #include @@ -97,4 +97,4 @@ hex_dump(unsigned char *data, int size) } -#endif /* _SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */ +#endif /* SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */ diff --git a/scripts/source-maintenance.sh b/scripts/source-maintenance.sh index 789d74f7a4..0750ba797b 100755 --- a/scripts/source-maintenance.sh +++ b/scripts/source-maintenance.sh @@ -34,6 +34,14 @@ srcformat () PWD=`pwd` #echo "FORMAT: ${PWD}..." +# +# Scan for incorrect use of #ifdef/#ifndef +# +grep -E "ifn?def .*_SQUID_" ./* | grep -v -E "_H$" | while read f; do echo "PROBLEM?: ${PWD} ${f}"; done + +# +# Scan for file-specific actions +# for FILENAME in `ls -1`; do case ${FILENAME} in @@ -65,23 +73,18 @@ for FILENAME in `ls -1`; do case ${FILENAME} in *.c|*.cc) FI=`grep "#include" ${FILENAME} | head -1`; - if test "${FI}" != "#include \"config.h\"" -a "${FI}" != "#include \"squid.h\"" ; then + if test "${FI}" != "#include \"config.h\"" -a "${FI}" != "#include \"squid.h\"" -a "${FILENAME}" != "cf_gen.cc"; then echo "ERROR: ${PWD}/${FILENAME} does not include config.h or squid.h first!" fi ;; *.h|*.cci) FI=`grep "#include \"config.h\"" ${FILENAME}`; - if test "x${FI}" != "x" ; then + if test "x${FI}" != "x" -a "${FILENAME}" != "squid.h"; then echo "ERROR: ${PWD}/${FILENAME} duplicate include of config.h" fi ;; esac - # - # Scan for incorrect use of #ifdef/#ifndef - # - grep -R -E "ifn?def .*_SQUID_" ./* | grep -v -E "_H$" | while read f; do echo "PROBLEM?: ${f}"; done - # # DEBUG Section list maintenance # diff --git a/src/DiskIO/DiskDaemon/diomsg.h b/src/DiskIO/DiskDaemon/diomsg.h index 5f735b3d42..897985d408 100644 --- a/src/DiskIO/DiskDaemon/diomsg.h +++ b/src/DiskIO/DiskDaemon/diomsg.h @@ -4,8 +4,8 @@ * Internal declarations for the diskd routines */ -#ifndef __SQUID_DIOMSG_H__ -#define __SQUID_DIOMSG_H__ +#ifndef SQUID_DIOMSG_H__ +#define SQUID_DIOMSG_H__ enum { _MQD_NOP, @@ -33,4 +33,4 @@ struct diomsg { static const int msg_snd_rcv_sz; }; -#endif /* __SQUID_DIOMSG_H__ */ +#endif /* SQUID_DIOMSG_H__ */ diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index 38a54a0bf2..58ada87eb4 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -376,7 +376,7 @@ squidaio_thread_loop(void *ptr) sigemptyset(&newSig); sigaddset(&newSig, SIGPIPE); sigaddset(&newSig, SIGCHLD); -#ifdef _SQUID_LINUX_THREADS_ +#if defined(_SQUID_LINUX_THREADS_) sigaddset(&newSig, SIGQUIT); sigaddset(&newSig, SIGTRAP); diff --git a/src/HttpHdrCc.h b/src/HttpHdrCc.h index e0603727ba..9b56771a3f 100644 --- a/src/HttpHdrCc.h +++ b/src/HttpHdrCc.h @@ -32,7 +32,6 @@ #ifndef SQUID_HTTPHDRCC_H #define SQUID_HTTPHDRCC_H -#include "config.h" #include "MemPool.h" #include "SquidString.h" diff --git a/src/dnsserver.cc b/src/dnsserver.cc index 420921f693..75569fbbb1 100644 --- a/src/dnsserver.cc +++ b/src/dnsserver.cc @@ -347,11 +347,11 @@ usage(void) ); } -#ifdef _SQUID_RES_NSADDR6_LARRAY +#if defined(_SQUID_RES_NSADDR6_LARRAY) /// \ingroup dnsserver #define _SQUID_RES_NSADDR6_LIST(i) _SQUID_RES_NSADDR6_LARRAY[i].sin6_addr #endif -#ifdef _SQUID_RES_NSADDR6_LPTR +#if defined(_SQUID_RES_NSADDR6_LPTR) /// \ingroup dnsserver #define _SQUID_RES_NSADDR6_LIST(i) _SQUID_RES_NSADDR6_LPTR[i]->sin6_addr #endif @@ -366,14 +366,14 @@ usage(void) void squid_res_setservers(int reset) { -#if defined(_SQUID_FREEBSD_) && defined(_SQUID_RES_NSADDR6_COUNT) +#if _SQUID_FREEBSD_ && defined(_SQUID_RES_NSADDR6_COUNT) /* Only seems to be valid on FreeBSD 5.5 where _res_ext was provided without an ns6addr counter! */ /* Gone again on FreeBSD 6.2 along with _res_ext itself in any form. */ int ns6count = 0; #endif #if HAVE_RES_INIT Ip::Address ipa; -#ifdef _SQUID_RES_NSADDR_LIST +#if defined(_SQUID_RES_NSADDR_LIST) extern char *optarg; #endif #endif diff --git a/src/errorpage.cc b/src/errorpage.cc index eb3b22223b..c4b3e83c66 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -66,7 +66,7 @@ */ -#ifndef DEFAULT_SQUID_ERROR_DIR +#if !defined(DEFAULT_SQUID_ERROR_DIR) /** Where to look for errors if config path fails. \note Please use ./configure --datadir=/path instead of patching */ diff --git a/src/main.cc b/src/main.cc index 64eae87481..068f862616 100644 --- a/src/main.cc +++ b/src/main.cc @@ -419,26 +419,18 @@ mainParseOptions(int argc, char *argv[]) opt_send_signal = SIGHUP; else if (!strncmp(optarg, "rotate", strlen(optarg))) /** \li On rotate send SIGQUIT or SIGUSR1. */ -#ifdef _SQUID_LINUX_THREADS_ - +#if defined(_SQUID_LINUX_THREADS_) opt_send_signal = SIGQUIT; - #else - opt_send_signal = SIGUSR1; - #endif else if (!strncmp(optarg, "debug", strlen(optarg))) /** \li On debug send SIGTRAP or SIGUSR2. */ -#ifdef _SQUID_LINUX_THREADS_ - +#if defined(_SQUID_LINUX_THREADS_) opt_send_signal = SIGTRAP; - #else - opt_send_signal = SIGUSR2; - #endif else if (!strncmp(optarg, "shutdown", strlen(optarg))) @@ -1145,7 +1137,7 @@ mainInitialize(void) if (!configured_once) writePidFile(); /* write PID file */ -#ifdef _SQUID_LINUX_THREADS_ +#if defined(_SQUID_LINUX_THREADS_) squid_signal(SIGQUIT, rotate_logs, SA_RESTART); diff --git a/src/mgr/BasicActions.cc b/src/mgr/BasicActions.cc index d1ec0f6f33..f98a9c7251 100644 --- a/src/mgr/BasicActions.cc +++ b/src/mgr/BasicActions.cc @@ -96,7 +96,7 @@ Mgr::RotateAction::dump(StoreEntry* entry) { debugs(16, DBG_IMPORTANT, "Rotate Logs by Cache Manager command."); storeAppendPrintf(entry, "Rotating Squid Process Logs ...."); -#ifdef _SQUID_LINUX_THREADS_ +#if defined(_SQUID_LINUX_THREADS_) rotate_logs(SIGQUIT); #else rotate_logs(SIGUSR1); diff --git a/tools/purge/conffile.hh b/tools/purge/conffile.hh index ffb87c4e62..8d5d5af9a2 100644 --- a/tools/purge/conffile.hh +++ b/tools/purge/conffile.hh @@ -55,9 +55,9 @@ typedef int bool; #endif /* __cplusplus */ -#ifndef DEFAULT_SQUID_CONF +#if !defined(DEFAULT_SQUID_CONF) #define DEFAULT_SQUID_CONF "/usr/local/squid/etc/squid.conf" -#endif // DEFAULT_SQUID_CONF +#endif #include // FILE* #include // minimum STL container diff --git a/tools/purge/squid-tlv.hh b/tools/purge/squid-tlv.hh index 1d9316d97e..191125e33a 100644 --- a/tools/purge/squid-tlv.hh +++ b/tools/purge/squid-tlv.hh @@ -34,8 +34,8 @@ // Revision 1.1 1999/06/15 21:10:16 voeckler // Initial revision // -#ifndef _SQUID_TLV_HH -#define _SQUID_TLV_HH +#ifndef SQUID_TLV_HH +#define SQUID_TLV_HH #if !defined(__cplusplus) #if defined(__GNUC__) || defined(__GNUG__) @@ -117,4 +117,4 @@ private: SquidTLV* tail; }; -#endif // _SQUID_TLV_HH +#endif // SQUID_TLV_HH