modules/core/m_join.c: remove global variable mbuf

This commit is contained in:
Simon Arlott 2017-07-29 23:09:16 +01:00 committed by Aaron Jones
parent 55ae03aee1
commit 6420b39ad0
No known key found for this signature in database
GPG key ID: 8AF0737488AB3012

View file

@ -75,7 +75,7 @@ static void do_join_0(struct Client *client_p, struct Client *source_p);
static int check_channel_name_loc(struct Client *source_p, const char *name); static int check_channel_name_loc(struct Client *source_p, const char *name);
static void send_join_error(struct Client *source_p, int numeric, const char *name); static void send_join_error(struct Client *source_p, int numeric, const char *name);
static void set_final_mode(struct Mode *mode, struct Mode *oldmode); static char *set_final_mode(char *mbuf, struct Mode *mode, struct Mode *oldmode);
static void remove_our_modes(struct Channel *chptr, struct Client *source_p); static void remove_our_modes(struct Channel *chptr, struct Client *source_p);
static void remove_ban_list(struct Channel *chptr, struct Client *source_p, static void remove_ban_list(struct Channel *chptr, struct Client *source_p,
@ -84,7 +84,6 @@ static void remove_ban_list(struct Channel *chptr, struct Client *source_p,
static char modebuf[MODEBUFLEN]; static char modebuf[MODEBUFLEN];
static char parabuf[MODEBUFLEN]; static char parabuf[MODEBUFLEN];
static const char *para[MAXMODEPARAMS]; static const char *para[MAXMODEPARAMS];
static char *mbuf;
static int pargs; static int pargs;
/* Check what we will forward to, without sending any notices to the user /* Check what we will forward to, without sending any notices to the user
@ -419,7 +418,7 @@ ms_join(struct Client *client_p, struct Client *source_p, int parc, const char *
if(parv[2][0] == '&') if(parv[2][0] == '&')
return 0; return 0;
mbuf = modebuf; char *mbuf = modebuf;
mode.key[0] = mode.forward[0] = '\0'; mode.key[0] = mode.forward[0] = '\0';
mode.mode = mode.limit = mode.join_num = mode.join_time = 0; mode.mode = mode.limit = mode.join_num = mode.join_time = 0;
@ -465,7 +464,7 @@ ms_join(struct Client *client_p, struct Client *source_p, int parc, const char *
/* Lost the TS, other side wins, so remove modes on this side */ /* Lost the TS, other side wins, so remove modes on this side */
if(!keep_our_modes) if(!keep_our_modes)
{ {
set_final_mode(&mode, &chptr->mode); mbuf = set_final_mode(mbuf, &mode, &chptr->mode);
chptr->mode = mode; chptr->mode = mode;
remove_our_modes(chptr, source_p); remove_our_modes(chptr, source_p);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head)
@ -557,7 +556,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
else else
fakesource_p = source_p; fakesource_p = source_p;
mbuf = modebuf; char *mbuf = modebuf;
newts = atol(parv[1]); newts = atol(parv[1]);
s = parv[3]; s = parv[3];
@ -721,7 +720,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
chptr->join_count = chptr->join_delta = 0; chptr->join_count = chptr->join_delta = 0;
} }
set_final_mode(&mode, oldmode); mbuf = set_final_mode(mbuf, &mode, oldmode);
chptr->mode = mode; chptr->mode = mode;
/* Lost the TS, other side wins, so remove modes on this side */ /* Lost the TS, other side wins, so remove modes on this side */
@ -1056,8 +1055,8 @@ send_join_error(struct Client *source_p, int numeric, const char *name)
} }
} }
static void static char *
set_final_mode(struct Mode *mode, struct Mode *oldmode) set_final_mode(char *mbuf, struct Mode *mode, struct Mode *oldmode)
{ {
int dir = MODE_QUERY; int dir = MODE_QUERY;
char *pbuf = parabuf; char *pbuf = parabuf;
@ -1175,7 +1174,9 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
len = rb_sprintf(pbuf, "%s ", mode->forward); len = rb_sprintf(pbuf, "%s ", mode->forward);
pbuf += len; pbuf += len;
} }
*mbuf = '\0'; *mbuf = '\0';
return mbuf;
} }
/* /*
@ -1195,7 +1196,7 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p)
int count = 0; int count = 0;
int i; int i;
mbuf = lmodebuf; char *mbuf = lmodebuf;
*mbuf++ = '-'; *mbuf++ = '-';
for(i = 0; i < MAXMODEPARAMS; i++) for(i = 0; i < MAXMODEPARAMS; i++)
@ -1298,7 +1299,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p,
pbuf = lparabuf; pbuf = lparabuf;
cur_len = mlen = rb_sprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname); cur_len = mlen = rb_sprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname);
mbuf = lmodebuf + mlen; char *mbuf = lmodebuf + mlen;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
{ {