repo: ngircd action: commit revision: path_from: revision_from: c7de505c919c5f550d848f9cafae99532bc1f789: path_to: revision_to:
commit c7de505c919c5f550d848f9cafae99532bc1f789 Author: MichiDate: Sun Jan 1 13:12:54 2023 +0100 Make the debug loglevel always available 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. diff --git a/src/ngircd/client.c b/src/ngircd/client.c
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -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- */
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
--- a/src/ngircd/client.h +++ b/src/ngircd/client.h @@ -182,9 +182,7 @@ GLOBAL void Client_UpdateCloakedHostname PARAMS((CLIENT *Client, const char *hostname)); -#ifdef DEBUG GLOBAL void Client_DebugDump PARAMS((void)); -#endif #endif diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -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.
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
--- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -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 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -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- */
diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h
--- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -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 diff --git a/src/ngircd/log.c b/src/ngircd/log.c
--- a/src/ngircd/log.c
+++ b/src/ngircd/log.c
@@ -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);
diff --git a/src/ngircd/log.h b/src/ngircd/log.h
--- a/src/ngircd/log.h
+++ b/src/ngircd/log.h
@@ -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
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -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 use file 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" );
diff --git a/src/ngircd/ngircd.h b/src/ngircd/ngircd.h
--- a/src/ngircd/ngircd.h +++ b/src/ngircd/ngircd.h @@ -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) */ diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c
--- a/src/ngircd/numeric.c +++ b/src/ngircd/numeric.c @@ -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); diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c
--- a/src/ngircd/proc.c
+++ b/src/ngircd/proc.c
@@ -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);
}
}
diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c
--- a/src/ngircd/resolve.c
+++ b/src/ngircd/resolve.c
@@ -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);
diff --git a/src/ngircd/sighandlers.c b/src/ngircd/sighandlers.c
--- a/src/ngircd/sighandlers.c
+++ b/src/ngircd/sighandlers.c
@@ -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);
}
diff --git a/src/portab/portab.h b/src/portab/portab.h
--- a/src/portab/portab.h +++ b/src/portab/portab.h @@ -19,6 +19,8 @@ #include "config.h" +/* remove assert() macro at compile time if DEBUG is not set. */ + #ifndef DEBUG # define NDEBUG #endif
-----END OF PAGE-----