]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Make the debug loglevel always available
authormichi <michi+ngircd@dataswamp.org>
Sun, 1 Jan 2023 12:12:54 +0000 (13:12 +0100)
committerAlexander Barton <alex@barton.de>
Mon, 2 Jan 2023 21:39:16 +0000 (22:39 +0100)
This basically means to unifdef DEBUG in (almost) all places.
We keep it in src/portab/portab.h so DEBUG stays available to
enable assert(). Also add a comment about this.

15 files changed:
src/ngircd/client.c
src/ngircd/client.h
src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/conn.c
src/ngircd/conn.h
src/ngircd/log.c
src/ngircd/log.h
src/ngircd/ngircd.c
src/ngircd/ngircd.h
src/ngircd/numeric.c
src/ngircd/proc.c
src/ngircd/resolve.c
src/ngircd/sighandlers.c
src/portab/portab.h

index c957ac73b029ea267edf45ac496a3e0f7684157c..06c34bbf8158209bec0db822b401854717de071c 100644 (file)
@@ -698,10 +698,8 @@ Client_ID( CLIENT *Client )
 {
        assert( Client != NULL );
 
-#ifdef DEBUG
        if(Client->type == CLIENT_USER)
                assert(strlen(Client->id) < Conf_MaxNickLength);
-#endif
 
        if( Client->id[0] ) return Client->id;
        else return "*";
@@ -1694,7 +1692,6 @@ Client_Announce(CLIENT * Client, CLIENT * Prefix, CLIENT * User)
 } /* Client_Announce */
 
 
-#ifdef DEBUG
 
 GLOBAL void
 Client_DebugDump(void)
@@ -1713,7 +1710,6 @@ Client_DebugDump(void)
        }
 } /* Client_DumpClients */
 
-#endif
 
 
 /* -eof- */
index 4185d2176ebd2e4ba7a65391f254c03cfe76a808..f6f9525b9c40beaaa9924dd43c684167192581ce 100644 (file)
@@ -182,9 +182,7 @@ GLOBAL void Client_UpdateCloakedHostname PARAMS((CLIENT *Client,
                                                 const char *hostname));
 
 
-#ifdef DEBUG
 GLOBAL void Client_DebugDump PARAMS((void));
-#endif
 
 #endif
 
index a748f3c4dab198bae56da136043bf804dd1ec8fd..860aea8f607f12aeecc849fdd1af68d0bb38bce8 100644 (file)
@@ -2046,9 +2046,7 @@ Validate_Config(bool Configtest, bool Rehash)
 {
        /* Validate configuration settings. */
 
-#ifdef DEBUG
        int i, servers, servers_once;
-#endif
        bool config_valid = true;
        char *ptr;
 
@@ -2122,7 +2120,6 @@ Validate_Config(bool Configtest, bool Rehash)
                             "Maximum penalty increase ('MaxPenaltyTime') is set to %ld, this is not recommended!",
                             Conf_MaxPenaltyTime);
 
-#ifdef DEBUG
        servers = servers_once = 0;
        for (i = 0; i < MAX_SERVERS; i++) {
                if (Conf_Server[i].name[0]) {
@@ -2135,7 +2132,6 @@ Validate_Config(bool Configtest, bool Rehash)
            array_length(&Conf_Opers, sizeof(struct Conf_Oper)),
            servers, servers_once,
            array_length(&Conf_Channels, sizeof(struct Conf_Channel)));
-#endif
 
        return config_valid;
 }
@@ -2222,7 +2218,6 @@ va_dcl
                Log(Level, "%s", msg);
 }
 
-#ifdef DEBUG
 
 /**
  * Dump internal state of the "configuration module".
@@ -2245,7 +2240,6 @@ Conf_DebugDump(void)
        }
 }
 
-#endif
 
 /**
  * Initialize server configuration structure to default values.
index a02f5e1431847b9af212593ab8bc8f736abcc886..97ce336d0796d7f4c4324d0e0332c043d7b5e114 100644 (file)
@@ -280,9 +280,7 @@ GLOBAL bool Conf_SSLInUse PARAMS((void));
 /* Password required by WEBIRC command */
 GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
 
-#ifdef DEBUG
 GLOBAL void Conf_DebugDump PARAMS((void));
-#endif
 
 
 #endif
index 7e7f6e65181bd53032c78eb1c719952a84e90b40..5dd581b70e6de47975c7db83c0f5061c79909afd 100644 (file)
@@ -2341,10 +2341,8 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events )
 
                Class_HandleServerBans(c);
        }
-#ifdef DEBUG
        else
                LogDebug("Resolver: discarding result for already registered connection %d.", i);
-#endif
 } /* cb_Read_Resolver_Result */
 
 /**
@@ -2688,7 +2686,6 @@ Conn_SetCertFp(UNUSED CONN_ID Idx, UNUSED const char *fingerprint)
 
 #endif /* SSL_SUPPORT */
 
-#ifdef DEBUG
 
 /**
  * Dump internal state of the "connection module".
@@ -2712,6 +2709,5 @@ Conn_DebugDump(void)
        }
 } /* Conn_DumpClients */
 
-#endif /* DEBUG */
 
 /* -eof- */
index 869477f091f69f2f9ed2d7f6b40dbb8c7109a85b..ca64ad205e6f3595d4f5a7c1b0b0cca2e3e3706b 100644 (file)
@@ -166,9 +166,7 @@ GLOBAL long Conn_GetAuthPing PARAMS((CONN_ID Idx));
 GLOBAL void Conn_SetAuthPing PARAMS((CONN_ID Idx, long ID));
 #endif
 
-#ifdef DEBUG
 GLOBAL void Conn_DebugDump PARAMS((void));
-#endif
 
 #endif
 
index a47ce92cd81571025a446ecd0f54b8553dcf9020..e036b0158cdae1299cdd0fa03c053dc18d5b78fc 100644 (file)
@@ -121,7 +121,6 @@ Log_Exit( void )
  * @param Format Format string like printf().
  * @param ... Further arguments.
  */
-#ifdef DEBUG
 # ifdef PROTOTYPES
 GLOBAL void
 LogDebug( const char *Format, ... )
@@ -145,7 +144,6 @@ va_dcl
        va_end( ap );
        Log(LOG_DEBUG, "%s", msg);
 }
-#endif /* DEBUG */
 
 
 /**
@@ -184,11 +182,7 @@ va_dcl
        }
        else snotice = false;
 
-#ifdef DEBUG
        if(( Level == LOG_DEBUG ) && ( ! NGIRCd_Debug )) return;
-#else
-       if( Level == LOG_DEBUG ) return;
-#endif
 
 #ifdef PROTOTYPES
        va_start( ap, Format );
@@ -215,20 +209,16 @@ Log_Init_Subprocess(char UNUSED *Name)
 #ifdef SYSLOG
        openlog(PACKAGE, LOG_CONS|LOG_PID, Conf_SyslogFacility);
 #endif
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "%s sub-process starting, PID %ld.",
                     Name, (long)getpid());
-#endif
 }
 
 
 GLOBAL void
 Log_Exit_Subprocess(char UNUSED *Name)
 {
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "%s sub-process %ld done.",
                     Name, (long)getpid());
-#endif
 #ifdef SYSLOG
        closelog( );
 #endif
@@ -251,13 +241,8 @@ va_dcl
 
        assert(Format != NULL);
 
-#ifdef DEBUG
        if ((Level == LOG_DEBUG) && (!NGIRCd_Debug))
                return;
-#else
-       if (Level == LOG_DEBUG)
-               return;
-#endif
 
 #ifdef PROTOTYPES
        va_start(ap, Format);
index f582e6c85bcda40f9f7524b286311e4bb5f277f8..85d00d9f6a16cd3c6f496efe574087be4d271269 100644 (file)
@@ -40,20 +40,14 @@ GLOBAL void Log_ReInit PARAMS((void));
 
 GLOBAL void Log_ServerNotice PARAMS((char UserMode, const char *Format, ...));
 
-#ifdef DEBUG
 GLOBAL void LogDebug PARAMS(( const char *Format, ... ));
-#else
-static inline void LogDebug PARAMS(( UNUSED const char *Format, ... )){/* Do nothing. The compiler should optimize this out, please ;-) */}
-#endif
 
 GLOBAL void Log_Init_Subprocess PARAMS((char *Name));
 GLOBAL void Log_Exit_Subprocess PARAMS((char *Name));
 
 GLOBAL void Log_Subprocess PARAMS((const int Level, const char *Format, ...));
 
-#ifdef DEBUG
 GLOBAL void Log_InitErrorfile PARAMS(( void ));
-#endif
 
 #endif
 
index eba853fcf98b2ad93e5fb9621df21d3ded01379d..76ea8d38b7f31d6b1951f9f4d6f4490b208cb8da 100644 (file)
@@ -88,9 +88,7 @@ main(int argc, const char *argv[])
 
        NGIRCd_SignalQuit = NGIRCd_SignalRestart = false;
        NGIRCd_Passive = false;
-#ifdef DEBUG
        NGIRCd_Debug = false;
-#endif
 #ifdef SNIFFER
        NGIRCd_Sniffer = false;
 #endif
@@ -117,12 +115,10 @@ main(int argc, const char *argv[])
                                configtest = true;
                                ok = true;
                        }
-#ifdef DEBUG
                        if (strcmp(argv[i], "--debug") == 0) {
                                NGIRCd_Debug = true;
                                ok = true;
                        }
-#endif
                        if (strcmp(argv[i], "--help") == 0) {
                                Show_Version();
                                puts(""); Show_Help( ); puts( "" );
@@ -151,12 +147,10 @@ main(int argc, const char *argv[])
                        /* short option */
                        for (n = 1; n < strlen(argv[i]); n++) {
                                ok = false;
-#ifdef DEBUG
                                if (argv[i][n] == 'd') {
                                        NGIRCd_Debug = true;
                                        ok = true;
                                }
-#endif
                                if (argv[i][n] == 'f') {
                                        if (!argv[i][n+1] && i+1 < argc) {
                                                /* Ok, next character is a blank */
@@ -223,10 +217,8 @@ main(int argc, const char *argv[])
 
        /* Debug level for "VERSION" command */
        NGIRCd_DebugLevel[0] = '\0';
-#ifdef DEBUG
        if (NGIRCd_Debug)
                strcpy(NGIRCd_DebugLevel, "1");
-#endif
 #ifdef SNIFFER
        if (NGIRCd_Sniffer) {
                NGIRCd_Debug = true;
@@ -349,13 +341,11 @@ Fill_Version(void)
        strlcat(NGIRCd_VersionAddition, "CHARCONV",
                sizeof NGIRCd_VersionAddition);
 #endif
-#ifdef DEBUG
        if (NGIRCd_VersionAddition[0])
                strlcat(NGIRCd_VersionAddition, "+",
                        sizeof NGIRCd_VersionAddition);
        strlcat(NGIRCd_VersionAddition, "DEBUG",
                sizeof NGIRCd_VersionAddition);
-#endif
 #ifdef IDENTAUTH
        if (NGIRCd_VersionAddition[0])
                strlcat(NGIRCd_VersionAddition, "+",
@@ -466,9 +456,7 @@ Show_Version( void )
 static void
 Show_Help( void )
 {
-#ifdef DEBUG
        puts( "  -d, --debug        log extra debug messages" );
-#endif
        puts( "  -f, --config <f>   use file <f> as configuration file" );
        puts( "  -n, --nodaemon     don't fork and don't detach from controlling terminal" );
        puts( "  -p, --passive      disable automatic connections to other servers" );
index 2efb8a943fb921e52f6574ff8851b424e43bdbdc..c3ae0feed731b6afc38e9af45b04c97243ede2a6 100644 (file)
@@ -35,10 +35,8 @@ GLOBAL char NGIRCd_Version[126];
 /** String specifying the compile-time options and target platform */
 GLOBAL char NGIRCd_VersionAddition[126];
 
-#ifdef DEBUG
 /** Flag indicating if debug mode is active (true) or not (false) */
 GLOBAL bool NGIRCd_Debug;
-#endif
 
 #ifdef SNIFFER
 /** Flag indication if sniffer is active (true) or not (false) */
index 8edb76e2169150951fbcdf9cb5611102b346d16f..997410683cc9e97a918b0e244c03a129b99c0906 100644 (file)
@@ -217,10 +217,8 @@ Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
        char *modes, *topic, *key;
        bool has_k, has_l;
 
-#ifdef DEBUG
        Log(LOG_DEBUG, "Sending CHANINFO commands for \"%s\" ...",
            Channel_Name(Chan));
-#endif
 
        modes = Channel_Modes(Chan);
        topic = Channel_Topic(Chan);
index d68d714da44d77eb9b158f128e0f52775b408315..af00dd3d3e9c81ca1345a10513ce8a4250292f15 100644 (file)
@@ -114,14 +114,10 @@ Proc_GenericSignalHandler(int Signal)
 {
        switch(Signal) {
        case SIGTERM:
-#ifdef DEBUG
                Log_Subprocess(LOG_DEBUG, "Child got TERM signal, exiting.");
-#endif
                exit(1);
        case SIGALRM:
-#ifdef DEBUG
                Log_Subprocess(LOG_DEBUG, "Child got ALARM signal, exiting.");
-#endif
                exit(1);
        }
 }
index afbef5b375122711763fe91bb80f56c1a929c8db..1931bc712e3be470672b92d484c7c9a9c9846f41 100644 (file)
@@ -93,9 +93,7 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short))
        pid = Proc_Fork(s, pipefd, cbfunc, RESOLVER_TIMEOUT);
        if (pid > 0) {
                /* Main process */
-#ifdef DEBUG
                Log( LOG_DEBUG, "Resolver for \"%s\" created (PID %d).", Host, pid );
-#endif
                return true;
        } else if( pid == 0 ) {
                /* Sub process */
@@ -140,15 +138,11 @@ Do_IdentQuery(int identsock, array *resolved_addr)
        if (identsock < 0)
                return;
 
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "Doing IDENT lookup on socket %d ...",
                       identsock);
-#endif
        res = ident_id( identsock, 10 );
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"",
                       identsock, res ? res : "(NULL)");
-#endif
        if (!res) /* no result */
                return;
        if (!array_cats(resolved_addr, res))
@@ -373,9 +367,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd)
 
        array_init(&resolved_addr);
        ng_ipaddr_tostr_r(Addr, tmp_ip_str);
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str);
-#endif
        if (!ReverseLookup(Addr, hostname, sizeof(hostname)))
                goto dns_done;
 
@@ -388,9 +380,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd)
                Log_Forgery_NoIP(tmp_ip_str, hostname);
                strlcpy(hostname, tmp_ip_str, sizeof(hostname));
        }
-#ifdef DEBUG
        Log_Subprocess(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname);
-#endif
  dns_done:
        len = strlen(hostname);
        hostname[len] = '\n';
@@ -417,10 +407,8 @@ Do_ResolveName( const char *Host, int w_fd )
         * to parent. */
        array IpAddrs;
        int af;
-#ifdef DEBUG
        ng_ipaddr_t *addr;
        size_t len;
-#endif
        Log_Subprocess(LOG_DEBUG, "Now resolving \"%s\" ...", Host);
 
        array_init(&IpAddrs);
@@ -440,7 +428,6 @@ Do_ResolveName( const char *Host, int w_fd )
                close(w_fd);
                return;
        }
-#ifdef DEBUG
        len = array_length(&IpAddrs, sizeof(*addr));
        assert(len > 0);
        addr = array_start(&IpAddrs);
@@ -449,7 +436,6 @@ Do_ResolveName( const char *Host, int w_fd )
                Log_Subprocess(LOG_DEBUG, "translated \"%s\" to %s.",
                                        Host, ng_ipaddr_tostr(addr));
        }
-#endif
        /* Write result into pipe to parent */
        ArrayWrite(w_fd, &IpAddrs);
 
index cfecd5d5fc869bd240d45ee1c4111dcd0adffbd5..4ed1a1255f4498b3820856dd8736d2a86cf0d33c 100644 (file)
@@ -41,7 +41,6 @@ static const int signals_catch[] = {
        SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGCHLD, SIGUSR1, SIGUSR2
 };
 
-#ifdef DEBUG
 
 static void
 Dump_State(void)
@@ -59,7 +58,6 @@ Dump_State(void)
        LogDebug("--- End of state dump ---");
 } /* Dump_State */
 
-#endif
 
 static void
 Signal_Block(int sig)
@@ -174,7 +172,6 @@ Signal_Handler(int Signal)
                while (waitpid( -1, NULL, WNOHANG) > 0)
                        ;
                return;
-#ifdef DEBUG
        case SIGUSR1:
                if (! NGIRCd_Debug) {
                        Log(LOG_INFO|LOG_snotice,
@@ -197,7 +194,6 @@ Signal_Handler(int Signal)
 #endif /* SNIFFER */
                }
                return;
-#endif
        }
 
        /*
@@ -226,7 +222,6 @@ Signal_Handler_BH(int Signal)
                /* re-read configuration */
                Rehash();
                break;
-#ifdef DEBUG
        case SIGUSR2:
                if (NGIRCd_Debug) {
                        Log(LOG_INFO|LOG_snotice,
@@ -236,7 +231,6 @@ Signal_Handler_BH(int Signal)
                break;
        default:
                LogDebug("Got signal %d! Ignored.", Signal);
-#endif
        }
        Signal_Unblock(Signal);
 }
index 43f2f9070c20caa28cdeee403d80b177dfa95b91..ebe81b49ff9ca511dbfe410539351952ea6794d5 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "config.h"
 
+/* remove assert() macro at compile time if DEBUG is not set. */
+
 #ifndef DEBUG
 # define NDEBUG
 #endif