From d2e0b78f6cbd6713e696c31a82b432d621fd768c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 8 Mar 2016 13:45:29 -0600 Subject: [PATCH 1/5] s_conf: remove YES/NO references --- ircd/s_conf.c | 87 +++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 6eaf80c0..4099dd33 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -675,10 +675,6 @@ rehash_bans(int sig) * of values later, put them in validate_conf(). */ -#define YES 1 -#define NO 0 -#define UNSET -1 - static void set_default_conf(void) { @@ -695,7 +691,7 @@ set_default_conf(void) #endif /* Don't reset hub, as that will break lazylinks */ - /* ServerInfo.hub = NO; */ + /* ServerInfo.hub = false; */ AdminInfo.name = NULL; AdminInfo.email = NULL; AdminInfo.description = NULL; @@ -706,39 +702,39 @@ set_default_conf(void) ConfigFileEntry.sasl_service = NULL; ConfigFileEntry.default_umodes = UMODE_INVISIBLE; - ConfigFileEntry.failed_oper_notice = YES; - ConfigFileEntry.anti_nick_flood = NO; - ConfigFileEntry.disable_fake_channels = NO; + ConfigFileEntry.failed_oper_notice = true; + ConfigFileEntry.anti_nick_flood = false; + ConfigFileEntry.disable_fake_channels = false; ConfigFileEntry.max_nick_time = 20; ConfigFileEntry.max_nick_changes = 5; ConfigFileEntry.max_accept = 20; ConfigFileEntry.max_monitor = 60; ConfigFileEntry.nick_delay = 900; /* 15 minutes */ - ConfigFileEntry.target_change = YES; + ConfigFileEntry.target_change = true; ConfigFileEntry.anti_spam_exit_message_time = 0; ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; - ConfigFileEntry.client_exit = YES; - ConfigFileEntry.dline_with_reason = YES; - ConfigFileEntry.kline_with_reason = YES; + ConfigFileEntry.client_exit = true; + ConfigFileEntry.dline_with_reason = true; + ConfigFileEntry.kline_with_reason = true; ConfigFileEntry.kline_delay = 0; - ConfigFileEntry.warn_no_nline = YES; - ConfigFileEntry.non_redundant_klines = YES; - ConfigFileEntry.stats_e_disabled = NO; - ConfigFileEntry.stats_o_oper_only = NO; + ConfigFileEntry.warn_no_nline = true; + ConfigFileEntry.non_redundant_klines = true; + ConfigFileEntry.stats_e_disabled = false; + ConfigFileEntry.stats_o_oper_only = false; ConfigFileEntry.stats_k_oper_only = 1; /* masked */ ConfigFileEntry.stats_i_oper_only = 1; /* masked */ - ConfigFileEntry.stats_P_oper_only = NO; - ConfigFileEntry.stats_c_oper_only = NO; - ConfigFileEntry.stats_y_oper_only = NO; - ConfigFileEntry.stats_h_oper_only = NO; - ConfigFileEntry.map_oper_only = YES; - ConfigFileEntry.operspy_admin_only = NO; + ConfigFileEntry.stats_P_oper_only = false; + ConfigFileEntry.stats_c_oper_only = false; + ConfigFileEntry.stats_y_oper_only = false; + ConfigFileEntry.stats_h_oper_only = false; + ConfigFileEntry.map_oper_only = true; + ConfigFileEntry.operspy_admin_only = false; ConfigFileEntry.pace_wait = 10; ConfigFileEntry.caller_id_wait = 60; ConfigFileEntry.pace_wait_simple = 1; - ConfigFileEntry.short_motd = NO; - ConfigFileEntry.no_oper_flood = NO; + ConfigFileEntry.short_motd = false; + ConfigFileEntry.no_oper_flood = false; ConfigFileEntry.fname_userlog = NULL; ConfigFileEntry.fname_fuserlog = NULL; ConfigFileEntry.fname_operlog = NULL; @@ -748,17 +744,17 @@ set_default_conf(void) ConfigFileEntry.fname_klinelog = NULL; ConfigFileEntry.fname_operspylog = NULL; ConfigFileEntry.fname_ioerrorlog = NULL; - ConfigFileEntry.hide_spoof_ips = YES; + ConfigFileEntry.hide_spoof_ips = true; ConfigFileEntry.hide_error_messages = 1; ConfigFileEntry.dots_in_ident = 0; ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; - ConfigFileEntry.use_whois_actually = YES; - ConfigFileEntry.burst_away = NO; - ConfigFileEntry.collision_fnc = YES; - ConfigFileEntry.resv_fnc = YES; - ConfigFileEntry.global_snotices = YES; - ConfigFileEntry.operspy_dont_care_user_info = NO; - ConfigFileEntry.use_propagated_bans = YES; + ConfigFileEntry.use_whois_actually = true; + ConfigFileEntry.burst_away = false; + ConfigFileEntry.collision_fnc = true; + ConfigFileEntry.resv_fnc = true; + ConfigFileEntry.global_snotices = true; + ConfigFileEntry.operspy_dont_care_user_info = false; + ConfigFileEntry.use_propagated_bans = true; ConfigFileEntry.max_ratelimit_tokens = 30; ConfigFileEntry.away_interval = 30; @@ -771,27 +767,27 @@ set_default_conf(void) ConfigFileEntry.oper_only_umodes = UMODE_SERVNOTICE; ConfigFileEntry.oper_snomask = SNO_GENERAL; - ConfigChannel.use_except = YES; - ConfigChannel.use_invex = YES; - ConfigChannel.use_forward = YES; - ConfigChannel.use_knock = YES; + ConfigChannel.use_except = true; + ConfigChannel.use_invex = true; + ConfigChannel.use_forward = true; + ConfigChannel.use_knock = true; ConfigChannel.knock_delay = 300; ConfigChannel.knock_delay_channel = 60; ConfigChannel.max_chans_per_user = 15; ConfigChannel.max_chans_per_user_large = 60; ConfigChannel.max_bans = 25; ConfigChannel.max_bans_large = 500; - ConfigChannel.only_ascii_channels = NO; - ConfigChannel.burst_topicwho = NO; - ConfigChannel.kick_on_split_riding = NO; + ConfigChannel.only_ascii_channels = false; + ConfigChannel.burst_topicwho = false; + ConfigChannel.kick_on_split_riding = false; ConfigChannel.default_split_user_count = 15000; ConfigChannel.default_split_server_count = 10; - ConfigChannel.no_join_on_split = NO; - ConfigChannel.no_create_on_split = YES; - ConfigChannel.resv_forcepart = YES; - ConfigChannel.channel_target_change = YES; - ConfigChannel.disable_local_channels = NO; + ConfigChannel.no_join_on_split = false; + ConfigChannel.no_create_on_split = true; + ConfigChannel.resv_forcepart = true; + ConfigChannel.channel_target_change = true; + ConfigChannel.disable_local_channels = false; ConfigChannel.displayed_usercount = 3; ConfigChannel.autochanmodes = MODE_TOPICLIMIT | MODE_NOPRIVMSGS; @@ -829,9 +825,6 @@ set_default_conf(void) alias_dict = rb_dictionary_create("alias", strcasecmp); } -#undef YES -#undef NO - /* * read_conf() * From 3089f59c10ecf4d4bc062b1e2a202734003d1a4a Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 8 Mar 2016 13:46:19 -0600 Subject: [PATCH 2/5] modules: using labs() for date math is unsafe --- ircd/modules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ircd/modules.c b/ircd/modules.c index fcb28477..72fe3f08 100644 --- a/ircd/modules.c +++ b/ircd/modules.c @@ -915,7 +915,7 @@ load_a_module(const char *path, int warn, int origin, int core) */ if(mheader->mapi_datecode != datecode && mheader->mapi_datecode > 0) { - long int delta = labs(datecode - mheader->mapi_datecode); + long int delta = datecode - mheader->mapi_datecode; if (delta > MOD_WARN_DELTA) { delta /= 86400; From 881acf00c65cfc75a4a3df3d6144c99b4f403671 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 8 Mar 2016 13:47:41 -0600 Subject: [PATCH 3/5] ircd: fix up some iwarn() calls which referred to L_MAIN --- ircd/dns.c | 2 +- ircd/modules.c | 3 +-- ircd/s_auth.c | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ircd/dns.c b/ircd/dns.c index 842e1037..5d936ea3 100644 --- a/ircd/dns.c +++ b/ircd/dns.c @@ -312,7 +312,7 @@ get_nameservers_cb(int resc, const char *resv[], int status, void *data) else { const char *error = resc ? resv[resc] : "Unknown error"; - iwarn(L_MAIN, "Error getting DNS servers: %s", error); + iwarn("Error getting DNS servers: %s", error); } } diff --git a/ircd/modules.c b/ircd/modules.c index 72fe3f08..09fc4a98 100644 --- a/ircd/modules.c +++ b/ircd/modules.c @@ -919,8 +919,7 @@ load_a_module(const char *path, int warn, int origin, int core) if (delta > MOD_WARN_DELTA) { delta /= 86400; - iwarn(L_MAIN, - "Module %s build date is out of sync with ircd build date by %ld days, expect problems", + iwarn("Module %s build date is out of sync with ircd build date by %ld days, expect problems", mod_basename, delta); sendto_realops_snomask(SNO_GENERAL, L_ALL, "Module %s build date is out of sync with ircd build date by %ld days, expect problems", diff --git a/ircd/s_auth.c b/ircd/s_auth.c index c87c7aa5..86ce272f 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -21,6 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * + */ /* * Changes: From ea111ea5449c763e08ca441b4bf1243af23a8b7c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 8 Mar 2016 13:52:48 -0600 Subject: [PATCH 4/5] ircd: further cleanup of YES/NO --- include/s_conf.h | 2 +- ircd/ircd.c | 2 +- ircd/s_conf.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/s_conf.h b/include/s_conf.h index 0bcd76c3..4f78fbdd 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -348,7 +348,7 @@ extern rb_dlink_node *find_prop_ban(unsigned int status, const char *user, const extern void deactivate_conf(struct ConfItem *, rb_dlink_node *, time_t); extern void replace_old_ban(struct ConfItem *); -extern void read_conf_files(int cold); +extern void read_conf_files(bool cold); extern int attach_conf(struct Client *, struct ConfItem *); extern int check_client(struct Client *client_p, struct Client *source_p, const char *); diff --git a/ircd/ircd.c b/ircd/ircd.c index d5726d05..e6ff1d2c 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -669,7 +669,7 @@ charybdis_main(int argc, char *argv[]) if (testing_conf) fprintf(stderr, "\nBeginning config test\n"); - read_conf_files(YES); /* cold start init conf files */ + read_conf_files(true); /* cold start init conf files */ mod_add_path(MODULE_DIR); mod_add_path(MODULE_DIR "/autoload"); diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 4099dd33..d952981b 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -1357,12 +1357,12 @@ get_printable_kline(struct Client *source_p, struct ConfItem *aconf, /* * read_conf_files * - * inputs - cold start YES or NO + * inputs - cold start * output - none * side effects - read all conf files needed, ircd.conf kline.conf etc. */ void -read_conf_files(int cold) +read_conf_files(bool cold) { const char *filename; From 959f5f368b27818c674a45ffb4a5f9cee82af6f1 Mon Sep 17 00:00:00 2001 From: Andrew Wilcox Date: Wed, 9 Mar 2016 01:08:23 -0600 Subject: [PATCH 5/5] core/m_error: Be consistent in strncmp usage --- modules/core/m_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/m_error.c b/modules/core/m_error.c index 14c0813f..dc933a24 100644 --- a/modules/core/m_error.c +++ b/modules/core/m_error.c @@ -68,7 +68,7 @@ is_safe_error(const char *message) if (!strncmp(message, "Terminated by ", 14)) return 1; - if (!ircncmp(message, "Closing Link", 12)) + if (!strncmp(message, "Closing Link", 12)) return 0; if (strchr(message, '[')) return 0;