More cleanup

This commit is contained in:
Matt Ullman 2016-03-22 22:53:56 -04:00
parent 5861f8a677
commit 66769bc1f8
8 changed files with 19 additions and 29 deletions

View file

@ -20,18 +20,16 @@ DECLARE_MODULE_AV2(echotags, NULL, NULL, echotags_clist, NULL, NULL, NULL, NULL,
static void static void
m_echotags(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) 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); 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]; struct MsgTag *tag = &msgbuf_p->tags[i];
if (tag->value) 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 else
sendto_one_notice(source_p, ":*** %d: %s", i, tag->key); sendto_one_notice(source_p, ":*** %zu: %s", i, tag->key);
} }
} }

View file

@ -73,7 +73,7 @@ struct Channel
unsigned int join_count; /* joins within delta */ unsigned int join_count; /* joins within delta */
unsigned int join_delta; /* last ts of join */ unsigned int join_delta; /* last ts of join */
unsigned long bants; time_t bants;
time_t channelts; time_t channelts;
char *chname; char *chname;
@ -93,7 +93,7 @@ struct membership
struct Client *client_p; struct Client *client_p;
unsigned int flags; unsigned int flags;
unsigned long bants; time_t bants;
}; };
#define BANLEN 195 #define BANLEN 195

View file

@ -54,7 +54,7 @@ typedef void (*MessageHandler) (struct MsgBuf *, struct Client *, struct Client
struct MessageEntry struct MessageEntry
{ {
MessageHandler handler; MessageHandler handler;
int min_para; size_t min_para;
}; };
/* Message table structure */ /* Message table structure */

View file

@ -35,7 +35,6 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
char *ch; char *ch;
char *parv[MAXPARA]; char *parv[MAXPARA];
size_t n_para; size_t n_para;
int i;
/* skip any leading spaces */ /* skip any leading spaces */
for (ch = line; *ch && *ch == ' '; ch++) for (ch = line; *ch && *ch == ' '; ch++)
@ -108,7 +107,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
return 1; return 1;
msgbuf->cmd = parv[0]; 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]); msgbuf_append_para(msgbuf, parv[i]);
return 0; return 0;
@ -117,9 +116,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
static int static int
msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask)
{ {
int i; for (size_t i = 0; i < msgbuf->n_tags; i++)
for (i = 0; i < msgbuf->n_tags; i++)
{ {
if ((msgbuf->tags[i].capmask & capmask) != 0) if ((msgbuf->tags[i].capmask & capmask) != 0)
return 1; return 1;
@ -131,14 +128,12 @@ msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask)
static void static void
msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
{ {
int i;
if (!msgbuf_has_matching_tags(msgbuf, capmask)) if (!msgbuf_has_matching_tags(msgbuf, capmask))
return; return;
*buf = '@'; *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) if ((msgbuf->tags[i].capmask & capmask) == 0)
continue; continue;
@ -185,11 +180,9 @@ msgbuf_unparse_prefix(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned
int int
msgbuf_unparse(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) msgbuf_unparse(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
{ {
int i;
msgbuf_unparse_prefix(buf, buflen, msgbuf, capmask); 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)) if (i == (msgbuf->n_para - 1))
{ {

View file

@ -246,13 +246,13 @@ handle_command(struct Message *mptr, struct MsgBuf *msgbuf_p, struct Client *cli
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Dropping server %s due to (invalid) command '%s'" "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); client_p->name, mptr->cmd, msgbuf_p->n_para, ehandler.min_para);
ilog(L_SERVER, 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); msgbuf_p->n_para, ehandler.min_para, mptr->cmd, client_p->name);
snprintf(squitreason, sizeof squitreason, 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); msgbuf_p->n_para, ehandler.min_para, mptr->cmd);
exit_client(client_p, client_p, client_p, squitreason); exit_client(client_p, client_p, client_p, squitreason);
return (-1); return (-1);
@ -278,7 +278,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
ehandler = mptr->handlers[ENCAP_HANDLER]; ehandler = mptr->handlers[ENCAP_HANDLER];
handler = ehandler.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]))) (ehandler.min_para && EmptyString(parv[ehandler.min_para - 1])))
return; return;

View file

@ -505,7 +505,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
struct membership *msptr; struct membership *msptr;
rb_dlink_node *ptr; rb_dlink_node *ptr;
rb_dlink_node *next_ptr; rb_dlink_node *next_ptr;
unsigned int current_capmask = 0; int current_capmask = 0;
struct MsgBuf msgbuf; struct MsgBuf msgbuf;
rb_linebuf_newbuf(&rb_linebuf_local); rb_linebuf_newbuf(&rb_linebuf_local);

View file

@ -452,7 +452,6 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
uint32_t len; uint32_t len;
uint8_t *certfp; uint8_t *certfp;
char *certfp_string; char *certfp_string;
int i;
if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN) if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN)
return; /* bogus message..drop it.. XXX should warn here */ 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; return;
rb_free(client_p->certfp); rb_free(client_p->certfp);
certfp_string = rb_malloc(len * 2 + 1); 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", snprintf(certfp_string + 2 * i, 3, "%02x",
certfp[i]); certfp[i]);
client_p->certfp = certfp_string; 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"; static const char *no_ssl_or_zlib = "ssld has neither SSL/TLS or zlib support killing all sslds";
rb_dlink_node *ptr, *next; rb_dlink_node *ptr, *next;
ssl_ctl_buf_t *ctl_buf; ssl_ctl_buf_t *ctl_buf;
int len; unsigned long len;
if(ctl->dead) if(ctl->dead)
return; return;

View file

@ -157,7 +157,7 @@ flattened_map(struct Client *client_p)
rb_dlink_node *ptr; rb_dlink_node *ptr;
struct Client *target_p; struct Client *target_p;
int i, len; int i, len;
int cnt = 0; unsigned long cnt = 0;
/* First display me as the root */ /* First display me as the root */
rb_strlcpy(buf, me.name, BUFSIZE); rb_strlcpy(buf, me.name, BUFSIZE);