From 66769bc1f8d394c8af2fd6086e31d193ace71ec6 Mon Sep 17 00:00:00 2001 From: Matt Ullman Date: Tue, 22 Mar 2016 22:53:56 -0400 Subject: [PATCH] More cleanup --- extensions/m_echotags.c | 8 +++----- include/channel.h | 4 ++-- include/msg.h | 2 +- ircd/msgbuf.c | 15 ++++----------- ircd/parse.c | 8 ++++---- ircd/send.c | 4 ++-- ircd/sslproc.c | 5 ++--- modules/m_map.c | 2 +- 8 files changed, 19 insertions(+), 29 deletions(-) diff --git a/extensions/m_echotags.c b/extensions/m_echotags.c index 858f7f90..bbf78aed 100644 --- a/extensions/m_echotags.c +++ b/extensions/m_echotags.c @@ -20,18 +20,16 @@ DECLARE_MODULE_AV2(echotags, NULL, NULL, echotags_clist, NULL, NULL, NULL, NULL, static void m_echotags(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { - int i; - sendto_one_notice(source_p, ":*** You sent %zu tags.", msgbuf_p->n_tags); - for (i = 0; i < msgbuf_p->n_tags; i++) + for (size_t i = 0; i < msgbuf_p->n_tags; i++) { struct MsgTag *tag = &msgbuf_p->tags[i]; if (tag->value) - sendto_one_notice(source_p, ":*** %d: %s => %s", i, tag->key, tag->value); + sendto_one_notice(source_p, ":*** %zu: %s => %s", i, tag->key, tag->value); else - sendto_one_notice(source_p, ":*** %d: %s", i, tag->key); + sendto_one_notice(source_p, ":*** %zu: %s", i, tag->key); } } diff --git a/include/channel.h b/include/channel.h index 44323b0e..9069296e 100644 --- a/include/channel.h +++ b/include/channel.h @@ -73,7 +73,7 @@ struct Channel unsigned int join_count; /* joins within delta */ unsigned int join_delta; /* last ts of join */ - unsigned long bants; + time_t bants; time_t channelts; char *chname; @@ -93,7 +93,7 @@ struct membership struct Client *client_p; unsigned int flags; - unsigned long bants; + time_t bants; }; #define BANLEN 195 diff --git a/include/msg.h b/include/msg.h index 34c69f82..3709163a 100644 --- a/include/msg.h +++ b/include/msg.h @@ -54,7 +54,7 @@ typedef void (*MessageHandler) (struct MsgBuf *, struct Client *, struct Client struct MessageEntry { MessageHandler handler; - int min_para; + size_t min_para; }; /* Message table structure */ diff --git a/ircd/msgbuf.c b/ircd/msgbuf.c index 4d47b186..50538d27 100644 --- a/ircd/msgbuf.c +++ b/ircd/msgbuf.c @@ -35,7 +35,6 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) char *ch; char *parv[MAXPARA]; size_t n_para; - int i; /* skip any leading spaces */ for (ch = line; *ch && *ch == ' '; ch++) @@ -108,7 +107,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) return 1; msgbuf->cmd = parv[0]; - for (i = 0; i < n_para; i++) + for (size_t i = 0; i < n_para; i++) msgbuf_append_para(msgbuf, parv[i]); return 0; @@ -117,9 +116,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) static int msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - - for (i = 0; i < msgbuf->n_tags; i++) + for (size_t i = 0; i < msgbuf->n_tags; i++) { if ((msgbuf->tags[i].capmask & capmask) != 0) return 1; @@ -131,14 +128,12 @@ msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) static void msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - if (!msgbuf_has_matching_tags(msgbuf, capmask)) return; *buf = '@'; - for (i = 0; i < msgbuf->n_tags; i++) + for (size_t i = 0; i < msgbuf->n_tags; i++) { if ((msgbuf->tags[i].capmask & capmask) == 0) continue; @@ -185,11 +180,9 @@ msgbuf_unparse_prefix(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int msgbuf_unparse(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - msgbuf_unparse_prefix(buf, buflen, msgbuf, capmask); - for (i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++) + for (size_t i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++) { if (i == (msgbuf->n_para - 1)) { diff --git a/ircd/parse.c b/ircd/parse.c index fd490367..e26afd13 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -246,13 +246,13 @@ handle_command(struct Message *mptr, struct MsgBuf *msgbuf_p, struct Client *cli sendto_realops_snomask(SNO_GENERAL, L_ALL, "Dropping server %s due to (invalid) command '%s'" - " with only %zu arguments (expecting %d).", + " with only %zu arguments (expecting %zu).", client_p->name, mptr->cmd, msgbuf_p->n_para, ehandler.min_para); ilog(L_SERVER, - "Insufficient parameters (%zu < %d) for command '%s' from %s.", + "Insufficient parameters (%zu < %zu) for command '%s' from %s.", msgbuf_p->n_para, ehandler.min_para, mptr->cmd, client_p->name); snprintf(squitreason, sizeof squitreason, - "Insufficient parameters (%zu < %d) for command '%s'", + "Insufficient parameters (%zu < %zu) for command '%s'", msgbuf_p->n_para, ehandler.min_para, mptr->cmd); exit_client(client_p, client_p, client_p, squitreason); return (-1); @@ -278,7 +278,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so ehandler = mptr->handlers[ENCAP_HANDLER]; handler = ehandler.handler; - if(parc < ehandler.min_para || + if((size_t)parc < ehandler.min_para || (ehandler.min_para && EmptyString(parv[ehandler.min_para - 1]))) return; diff --git a/ircd/send.c b/ircd/send.c index 6eec553a..a733f049 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -223,7 +223,7 @@ linebuf_put_msgvbuf(struct MsgBuf *msgbuf, buf_head_t *linebuf, unsigned int cap rb_linebuf_newbuf(linebuf); msgbuf_unparse_prefix(buf, sizeof buf, msgbuf, capmask); rb_linebuf_putprefix(linebuf, pattern, va, buf); -} +} /* linebuf_put_msgbuf * @@ -505,7 +505,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, struct membership *msptr; rb_dlink_node *ptr; rb_dlink_node *next_ptr; - unsigned int current_capmask = 0; + int current_capmask = 0; struct MsgBuf msgbuf; rb_linebuf_newbuf(&rb_linebuf_local); diff --git a/ircd/sslproc.c b/ircd/sslproc.c index b5c0ab29..6d53caf3 100644 --- a/ircd/sslproc.c +++ b/ircd/sslproc.c @@ -452,7 +452,6 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) uint32_t len; uint8_t *certfp; char *certfp_string; - int i; if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN) return; /* bogus message..drop it.. XXX should warn here */ @@ -465,7 +464,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) return; rb_free(client_p->certfp); certfp_string = rb_malloc(len * 2 + 1); - for(i = 0; i < len; i++) + for(uint32_t i = 0; i < len; i++) snprintf(certfp_string + 2 * i, 3, "%02x", certfp[i]); client_p->certfp = certfp_string; @@ -478,7 +477,7 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) static const char *no_ssl_or_zlib = "ssld has neither SSL/TLS or zlib support killing all sslds"; rb_dlink_node *ptr, *next; ssl_ctl_buf_t *ctl_buf; - int len; + unsigned long len; if(ctl->dead) return; diff --git a/modules/m_map.c b/modules/m_map.c index 8675fed8..6ba05e1f 100644 --- a/modules/m_map.c +++ b/modules/m_map.c @@ -157,7 +157,7 @@ flattened_map(struct Client *client_p) rb_dlink_node *ptr; struct Client *target_p; int i, len; - int cnt = 0; + unsigned long cnt = 0; /* First display me as the root */ rb_strlcpy(buf, me.name, BUFSIZE);