From 9279ad64613fa5130bc7afaa76adfc00cd7ff527 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 1 Mar 2015 23:46:20 +0100 Subject: [PATCH] Fix some compiler warnings about signed/unsigned comparison. --- modules/core/m_message.c | 2 +- modules/core/m_nick.c | 2 +- modules/m_monitor.c | 2 +- src/chmode.c | 2 +- src/hash.c | 6 +++--- src/ratelimit.c | 2 +- src/res.c | 2 +- src/s_auth.c | 4 +++- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 0313b137..bb8e5686 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -732,7 +732,7 @@ msg_client(enum message_type msgtype, !IsOper(target_p)) { if(rb_dlink_list_length(&source_p->localClient->allow_list) < - ConfigFileEntry.max_accept) + (unsigned long)ConfigFileEntry.max_accept) { rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list); rb_dlinkAddAlloc(source_p, &target_p->on_allow_list); diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index b9ed03fc..6e36698a 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -551,7 +551,7 @@ clean_nick(const char *nick, int loc_client) } /* nicklen is +1 */ - if(len >= NICKLEN && len >= ConfigFileEntry.nicklen) + if(len >= NICKLEN && (unsigned int)len >= ConfigFileEntry.nicklen) return 0; return 1; diff --git a/modules/m_monitor.c b/modules/m_monitor.c index 1d0d64df..7018b27d 100644 --- a/modules/m_monitor.c +++ b/modules/m_monitor.c @@ -80,7 +80,7 @@ add_monitor(struct Client *client_p, const char *nicks) continue; if(rb_dlink_list_length(&client_p->localClient->monitor_list) >= - ConfigFileEntry.max_monitor) + (unsigned long)ConfigFileEntry.max_monitor) { char buf[100]; diff --git a/src/chmode.c b/src/chmode.c index e131e453..37906113 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -256,7 +256,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const */ if(MyClient(source_p)) { - if((rb_dlink_list_length(&chptr->banlist) + rb_dlink_list_length(&chptr->exceptlist) + rb_dlink_list_length(&chptr->invexlist) + rb_dlink_list_length(&chptr->quietlist)) >= (chptr->mode.mode & MODE_EXLIMIT ? ConfigChannel.max_bans_large : ConfigChannel.max_bans)) + if((rb_dlink_list_length(&chptr->banlist) + rb_dlink_list_length(&chptr->exceptlist) + rb_dlink_list_length(&chptr->invexlist) + rb_dlink_list_length(&chptr->quietlist)) >= (unsigned long)(chptr->mode.mode & MODE_EXLIMIT ? ConfigChannel.max_bans_large : ConfigChannel.max_bans)) { sendto_one(source_p, form_str(ERR_BANLISTFULL), me.name, source_p->name, chptr->chname, realban); diff --git a/src/hash.c b/src/hash.c index 0b90aaa5..ce57a522 100644 --- a/src/hash.c +++ b/src/hash.c @@ -697,7 +697,7 @@ find_cli_fd_hash(int fd) } static void -output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest) +output_hash(struct Client *source_p, const char *name, int length, int *counts, unsigned long deepest) { unsigned long total = 0; int i; @@ -724,7 +724,7 @@ output_hash(struct Client *source_p, const char *name, int length, int *counts, (float) (total / (length - counts[0])), (float) (total / length)); sendto_one_numeric(source_p, RPL_STATSDEBUG, - "B :Average depth: %s Highest depth: %d", + "B :Average depth: %s Highest depth: %lu", buf, deepest); } @@ -741,7 +741,7 @@ static void count_hash(struct Client *source_p, rb_dlink_list *table, int length, const char *name) { int counts[11]; - int deepest = 0; + unsigned long deepest = 0; int i; memset(counts, 0, sizeof(counts)); diff --git a/src/ratelimit.c b/src/ratelimit.c index 7ef7c010..80a3701c 100644 --- a/src/ratelimit.c +++ b/src/ratelimit.c @@ -60,7 +60,7 @@ int ratelimit_client(struct Client *client_p, unsigned int penalty) } /* Don't make it impossible to execute anything. */ - if (penalty > ConfigFileEntry.max_ratelimit_tokens) + if (penalty > (unsigned int)ConfigFileEntry.max_ratelimit_tokens) penalty = ConfigFileEntry.max_ratelimit_tokens; if (client_p->localClient->ratelimit <= rb_current_time() - ConfigFileEntry.max_ratelimit_tokens) diff --git a/src/res.c b/src/res.c index be634e54..ee4fe790 100644 --- a/src/res.c +++ b/src/res.c @@ -76,7 +76,7 @@ struct reslist char sends; /* number of sends (>1 means resent) */ time_t sentat; time_t timeout; - unsigned int lastns; /* index of last server sent to */ + int lastns; /* index of last server sent to */ struct rb_sockaddr_storage addr; char *name; struct DNSQuery *query; /* query callback for this request */ diff --git a/src/s_auth.c b/src/s_auth.c index 253b8484..593ca56f 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -519,6 +519,7 @@ auth_connect_callback(rb_fde_t *F, int error, void *data) { struct AuthRequest *auth = data; char authbuf[32]; + int authlen; /* Check the error */ if(error != RB_OK) @@ -530,8 +531,9 @@ auth_connect_callback(rb_fde_t *F, int error, void *data) rb_snprintf(authbuf, sizeof(authbuf), "%u , %u\r\n", auth->rport, auth->lport); + authlen = strlen(authbuf); - if(rb_write(auth->F, authbuf, strlen(authbuf)) != strlen(authbuf)) + if(rb_write(auth->F, authbuf, authlen) != authlen) { auth_error(auth); return;