]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Source Maintenance: Optimizations and macro fixes
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 30 Oct 2011 02:42:27 +0000 (15:42 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 30 Oct 2011 02:42:27 +0000 (15:42 +1300)
* 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

20 files changed:
compat/strnstr.cc
compat/xstring.h
compat/xstrto.cc
helpers/basic_auth/PAM/basic_pam_auth.cc
helpers/digest_auth/LDAP/digest_common.h
helpers/digest_auth/eDirectory/digest_common.h
helpers/digest_auth/file/digest_common.h
include/RefCount.h
include/util.h
lib/ntlmauth/support_bits.cci
scripts/source-maintenance.sh
src/DiskIO/DiskDaemon/diomsg.h
src/DiskIO/DiskThreads/aiops.cc
src/HttpHdrCc.h
src/dnsserver.cc
src/errorpage.cc
src/main.cc
src/mgr/BasicActions.cc
tools/purge/conffile.hh
tools/purge/squid-tlv.hh

index 3c86e170c00eb7a88dd3b5ad35d49536d137f60a..7c2f058deda73822ef4e5268541ad15041526d60 100644 (file)
@@ -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_ */
index c5248bda8a50092cde686189af89fdcbdfb48b90..0b825d215f2a5961565debe6b60e15c203d83a36 100644 (file)
@@ -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 <string.h>
@@ -54,4 +54,4 @@ extern "C" {
 }
 #endif
 
-#endif /* _SQUID_COMPAT_XSTRING_H */
+#endif /* SQUID_COMPAT_XSTRING_H */
index 20bdeddab8a1b4752c110a3b903b36eadc07482b..1e83e05fb22214a51482a7c131d13d233530a284 100644 (file)
@@ -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_ */
index 6a103c58f748a4b1171a493c54a7f6f45afc90a7..3f8f0eee1c08c48ae0492f2dd0bb569505ea131f 100644 (file)
 #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
 
index 3f6fba38bf5095f730d3b5ed89368e37724fd0ac..039108e76c2f54bda08a41996e5a7442e3584f98 100644 (file)
@@ -8,8 +8,8 @@
  * Copyright (c) 2003  Robert Collins  <robertc@squid-cache.org>
  */
 
-#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 <stdio.h>
@@ -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_ */
index d403c2c3e08ed39ccc799b194d617036038618db..6f1bb672e119d9baa48f1c3c6cec7ecff169dcdb 100644 (file)
@@ -8,8 +8,8 @@
  * Copyright (c) 2003  Robert Collins  <robertc@squid-cache.org>
  */
 
-#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 <stdio.h>
@@ -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_ */
index 5c26bca6db465144ba7485b3ed4ef05bf0637fbe..f7dfaa8e6b47b1091f6a6d428867b87df89f8eec 100644 (file)
@@ -8,8 +8,8 @@
  * Copyright (c) 2003  Robert Collins  <robertc@squid-cache.org>
  */
 
-#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_ */
index 77ba37cac1004b3cbd2c846c1538ee977db548c8..8ddb9d240f4cc3d460e6e73bed56d819615ef30a 100644 (file)
@@ -32,8 +32,8 @@
  *
  */
 
-#ifndef _SQUID_REFCOUNT_H_
-#define _SQUID_REFCOUNT_H_
+#ifndef SQUID_REFCOUNT_H_
+#define SQUID_REFCOUNT_H_
 
 #if HAVE_IOSTREAM
 #include <iostream>
@@ -144,4 +144,4 @@ inline std::ostream &operator <<(std::ostream &os, const RefCount<C> &p)
         return os << "NULL";
 }
 
-#endif /* _SQUID_REFCOUNT_H_ */
+#endif /* SQUID_REFCOUNT_H_ */
index 18e62e7d40428e850a02d5af998ce16583cbbb53..4bcd24e0b4e6316b45e5d23914b04df7334ba0f0 100644 (file)
@@ -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
index 06083ca22d0808a6a4b4fd5f812e4499ee21797f..a13c5e9771d2190904825579556a3840b4bdae3d 100644 (file)
@@ -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 <string.h>
@@ -97,4 +97,4 @@ hex_dump(unsigned char *data, int size)
 
 }
 
-#endif /* _SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */
+#endif /* SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */
index 789d74f7a4728bca3e40b66d59149b73006e0ccc..0750ba797b2a90e3f42271adeeb5d87c863ef4fa 100755 (executable)
@@ -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
        #
index 5f735b3d4232c5dc71ec7cf3acc78a68c49d5191..897985d408ef32e46c1d3aaa7f921b05e2add882 100644 (file)
@@ -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__ */
index 38a54a0bf2ac03303ffb6af4cab696cf058a869f..58ada87eb4594e0db97e67299a105a67bc436be8 100644 (file)
@@ -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);
index e0603727badefc006a2305ee756d4d2015fdf4c2..9b56771a3fe3d15185146c36180853ab5ae822cc 100644 (file)
@@ -32,7 +32,6 @@
 #ifndef SQUID_HTTPHDRCC_H
 #define SQUID_HTTPHDRCC_H
 
-#include "config.h"
 #include "MemPool.h"
 #include "SquidString.h"
 
index 420921f6939b1646abd00ff209659eb2d3a4436d..75569fbbb193ca86bd5c68140b57f402c87b8f45 100644 (file)
@@ -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
index eb3b22223b9bcb4c1d26964d1dc1347c9da13bb8..c4b3e83c666f9517a860622f2a5d2a027bb8ca9f 100644 (file)
@@ -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
  */
index 64eae87481e78ab9a2bf4dc9826779214698195f..068f862616c5d21e2b42af5c4d7e858e74be806c 100644 (file)
@@ -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);
 
index d1ec0f6f33952e39b541880b70531451406e9b3a..f98a9c7251b99a2845bcda36328aba960d53353b 100644 (file)
@@ -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);
index ffb87c4e62520da9a11d1100faf406ea2cfdb543..8d5d5af9a263ca49e0f2b05a21b403d8855b03a7 100644 (file)
@@ -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 <stdio.h>      // FILE*
 #include <vector>      // minimum STL container
index 1d9316d97e9fd50a095b93ca466e963f0fc6752e..191125e33a4cac1f23389ab8d4e7e2ce29f66c88 100644 (file)
@@ -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