m_join: remove global variable mbuf

This commit is contained in:
Simon Arlott 2017-07-29 23:09:16 +01:00
parent 4c7d1de8f3
commit 2077757f2a
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24

View file

@ -74,7 +74,7 @@ static void do_join_0(struct Client *client_p, struct Client *source_p);
static bool check_channel_name_loc(struct Client *source_p, const char *name); static bool 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,
@ -83,7 +83,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
@ -406,6 +405,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
bool isnew; bool isnew;
bool keep_our_modes = true; bool keep_our_modes = true;
rb_dlink_node *ptr, *next_ptr; rb_dlink_node *ptr, *next_ptr;
char *mbuf;
/* special case for join 0 */ /* special case for join 0 */
if((parv[1][0] == '0') && (parv[1][1] == '\0') && parc == 2) if((parv[1][0] == '0') && (parv[1][1] == '\0') && parc == 2)
@ -460,7 +460,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
/* 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)
@ -531,6 +531,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
int i, joinc = 0, timeslice = 0; int i, joinc = 0, timeslice = 0;
static char empty[] = ""; static char empty[] = "";
rb_dlink_node *ptr, *next_ptr; rb_dlink_node *ptr, *next_ptr;
char *mbuf;
if(parc < 5) if(parc < 5)
return; return;
@ -704,7 +705,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
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 */
@ -1037,8 +1038,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;
@ -1157,6 +1158,8 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
pbuf += len; pbuf += len;
} }
*mbuf = '\0'; *mbuf = '\0';
return mbuf;
} }
/* /*
@ -1175,8 +1178,8 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p)
char *lpara[MAXMODEPARAMS]; char *lpara[MAXMODEPARAMS];
int count = 0; int count = 0;
int i; int i;
char *mbuf = lmodebuf;
mbuf = lmodebuf;
*mbuf++ = '-'; *mbuf++ = '-';
for(i = 0; i < MAXMODEPARAMS; i++) for(i = 0; i < MAXMODEPARAMS; i++)
@ -1275,6 +1278,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p,
char *pbuf; char *pbuf;
int count = 0; int count = 0;
int cur_len, mlen, plen; int cur_len, mlen, plen;
char *mbuf;
pbuf = lparabuf; pbuf = lparabuf;