1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 02:03:14 +02:00

More code cleanups to get rid of useless casts and other useless

structures such as:
-       lp->value.cp = (char *)MyMalloc(strlen(mask) + 1);
-       (void)strcpy(lp->value.cp, mask);
+       lp->value.cp = strdup(mask);
This commit is contained in:
Bram Matthys
2018-04-22 14:28:22 +02:00
parent 680715b1b5
commit d5d446c38d
25 changed files with 86 additions and 108 deletions
+24 -23
View File
@@ -555,8 +555,8 @@ void *cmodef_put_param(void *fld_in, char *param)
char *cmodef_get_param(void *r_in)
{
ChanFloodProt *r = (ChanFloodProt *)r_in;
static char retbuf[512];
ChanFloodProt *r = (ChanFloodProt *)r_in;
static char retbuf[512];
if (!r)
return NULL;
@@ -787,8 +787,8 @@ void cmodef_free_param(void *r)
void *cmodef_dup_struct(void *r_in)
{
ChanFloodProt *r = (ChanFloodProt *)r_in;
ChanFloodProt *w = (ChanFloodProt *)MyMalloc(sizeof(ChanFloodProt));
ChanFloodProt *r = (ChanFloodProt *)r_in;
ChanFloodProt *w = MyMallocEx(sizeof(ChanFloodProt));
memcpy(w, r, sizeof(ChanFloodProt));
return (void *)w;
@@ -796,11 +796,10 @@ ChanFloodProt *w = (ChanFloodProt *)MyMalloc(sizeof(ChanFloodProt));
int cmodef_sjoin_check(aChannel *chptr, void *ourx, void *theirx)
{
ChanFloodProt *our = (ChanFloodProt *)ourx;
ChanFloodProt *their = (ChanFloodProt *)theirx;
char *x;
int i;
ChanFloodProt *our = (ChanFloodProt *)ourx;
ChanFloodProt *their = (ChanFloodProt *)theirx;
char *x;
int i;
if (compare_floodprot_modes(our, their) == 0)
return EXSJ_SAME;
@@ -974,7 +973,7 @@ int floodprot_remote_nickchange(aClient *cptr, aClient *sptr, char *oldnick)
int floodprot_chanmode_del(aChannel *chptr, int modechar)
{
ChanFloodProt *chp;
ChanFloodProt *chp;
if (!IsFloodLimit(chptr))
return 0;
@@ -1099,7 +1098,7 @@ RemoveFld *removefld_list = NULL;
RemoveFld *floodprottimer_find(aChannel *chptr, char mflag)
{
RemoveFld *e;
RemoveFld *e;
for (e=removefld_list; e; e=e->next)
{
@@ -1131,9 +1130,9 @@ void strccat(char *s, char c)
*/
void floodprottimer_add(aChannel *chptr, char mflag, time_t when)
{
RemoveFld *e = NULL;
unsigned char add=1;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
RemoveFld *e = NULL;
unsigned char add=1;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
if (strchr(chp->timers_running, mflag))
{
@@ -1168,8 +1167,8 @@ ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
void floodprottimer_del(aChannel *chptr, char mflag)
{
RemoveFld *e;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
RemoveFld *e;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
if (chp && !strchr(chp->timers_running, mflag))
return; /* nothing to remove.. */
@@ -1193,7 +1192,8 @@ ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
long get_mode_bitbychar(char m)
{
aCtab *tab = &cFlagTab[0];
aCtab *tab = &cFlagTab[0];
while(tab->mode != 0x0)
{
if (tab->flag == m)
@@ -1258,7 +1258,8 @@ EVENT(modef_event)
void floodprottimer_stopchantimers(aChannel *chptr)
{
RemoveFld *e = removefld_list;
RemoveFld *e = removefld_list;
while(e)
{
if (e->chptr == chptr)
@@ -1272,7 +1273,7 @@ RemoveFld *e = removefld_list;
int do_floodprot(aChannel *chptr, int what)
{
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
if (!chp || !chp->l[what]) /* no +f or not restricted */
return 0;
@@ -1302,10 +1303,10 @@ ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
void do_floodprot_action(aChannel *chptr, int what, char *text)
{
char m;
int mode = 0;
Cmode_t extmode = 0;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
char m;
int mode = 0;
Cmode_t extmode = 0;
ChanFloodProt *chp = (ChanFloodProt *)GETPARASTRUCT(chptr, 'f');
m = chp->a[what];
if (!m)
+13 -10
View File
@@ -34,8 +34,11 @@ int link_can_join_limitexceeded(aClient *sptr, aChannel *chptr, char *key, char
MOD_INIT(link)
{
CmodeInfo req;
ModuleSetOptions(modinfo->handle, MOD_OPT_PERM_RELOADABLE, 1);
MARK_AS_OFFICIAL_MODULE(modinfo);
memset(&req, 0, sizeof(req));
req.paracount = 1;
req.is_ok = cmodeL_is_ok;
@@ -110,12 +113,12 @@ int cmodeL_is_ok(aClient *sptr, aChannel *chptr, char mode, char *para, int type
void *cmodeL_put_param(void *r_in, char *param)
{
aModeLEntry *r = (aModeLEntry *)r_in;
aModeLEntry *r = (aModeLEntry *)r_in;
if (!r)
{
/* Need to create one */
r = (aModeLEntry *)MyMallocEx(sizeof(aModeLEntry));
r = MyMallocEx(sizeof(aModeLEntry));
}
strlcpy(r->linked, param, sizeof(r->linked));
return (void *)r;
@@ -123,8 +126,8 @@ aModeLEntry *r = (aModeLEntry *)r_in;
char *cmodeL_get_param(void *r_in)
{
aModeLEntry *r = (aModeLEntry *)r_in;
static char retbuf[CHANNELLEN+1];
aModeLEntry *r = (aModeLEntry *)r_in;
static char retbuf[CHANNELLEN+1];
if (!r)
return NULL;
@@ -138,8 +141,8 @@ static char retbuf[CHANNELLEN+1];
*/
char *cmodeL_conv_param(char *param_in, aClient *sptr)
{
static char buf[CHANNELLEN+1];
char *p;
static char buf[CHANNELLEN+1];
char *p;
strlcpy(buf, param_in, sizeof(buf));
clean_channelname(buf);
@@ -159,8 +162,8 @@ void cmodeL_free_param(void *r)
void *cmodeL_dup_struct(void *r_in)
{
aModeLEntry *r = (aModeLEntry *)r_in;
aModeLEntry *w = (aModeLEntry *)MyMalloc(sizeof(aModeLEntry));
aModeLEntry *r = (aModeLEntry *)r_in;
aModeLEntry *w = MyMallocEx(sizeof(aModeLEntry));
memcpy(w, r, sizeof(aModeLEntry));
return (void *)w;
@@ -168,8 +171,8 @@ aModeLEntry *w = (aModeLEntry *)MyMalloc(sizeof(aModeLEntry));
int cmodeL_sjoin_check(aChannel *chptr, void *ourx, void *theirx)
{
aModeLEntry *our = (aModeLEntry *)ourx;
aModeLEntry *their = (aModeLEntry *)theirx;
aModeLEntry *our = (aModeLEntry *)ourx;
aModeLEntry *their = (aModeLEntry *)theirx;
if (!strcmp(our->linked, their->linked))
return EXSJ_SAME;
+1 -2
View File
@@ -76,8 +76,7 @@ CMD_FUNC(m_admin)
sendto_one(sptr, rpl_str(RPL_ADMINME), me.name, sptr->name, me.name);
/* cycle through the list backwards */
for (admin = conf_admin_tail; admin;
admin = (ConfigItem_admin *) admin->prev)
for (admin = conf_admin_tail; admin; admin = admin->prev)
{
if (!admin->next)
sendto_one(sptr, rpl_str(RPL_ADMINLOC1),
+1 -1
View File
@@ -89,7 +89,7 @@ CMD_FUNC(m_invite)
return -1;
}
if (!(acptr = find_person(parv[1], (aClient *)NULL)))
if (!(acptr = find_person(parv[1], NULL)))
{
sendto_one(sptr, err_str(ERR_NOSUCHNICK),
me.name, sptr->name, parv[1]);
+1 -1
View File
@@ -103,7 +103,7 @@ CMD_FUNC(m_kill)
path[TOPICLEN] = '\0';
if (MyClient(sptr))
user = (char *)canonize(user);
user = canonize(user);
for (p = NULL, nick = strtoken(&p, user, ","); nick;
nick = strtoken(&p, NULL, ","))
+1 -1
View File
@@ -101,7 +101,7 @@ CMD_FUNC(m_names)
}
}
chptr = find_channel(para, (aChannel *)NULL);
chptr = find_channel(para, NULL);
if (!chptr || (!ShowChannel(sptr, chptr) && !ValidatePermissionsForPath("override:see:names:secret",sptr,NULL,chptr,NULL)))
{
+1 -1
View File
@@ -65,7 +65,7 @@ int do_svsnolag(aClient *cptr, aClient *sptr, int parc, char *parv[], int show_c
if (parc < 3)
return 0;
if (!(acptr = find_person(parv[2], (aClient *)NULL)))
if (!(acptr = find_person(parv[2], NULL)))
return 0;
if (!MyClient(acptr))
+1 -1
View File
@@ -78,7 +78,7 @@ CMD_FUNC(m_swhois)
if (parc < 3)
return 0;
acptr = find_person(parv[1], (aClient *)NULL);
acptr = find_person(parv[1], NULL);
if (!acptr)
return 0;
+1 -1
View File
@@ -260,7 +260,7 @@ int webirc_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
if (!ce || !ce->ce_varname || strcmp(ce->ce_varname, "webirc"))
return 0; /* not interested */
webirc = (ConfigItem_webirc *) MyMallocEx(sizeof(ConfigItem_webirc));
webirc = MyMallocEx(sizeof(ConfigItem_webirc));
webirc->type = WEBIRC_WEBIRC; /* default */
for (cep = ce->ce_entries; cep; cep = cep->ce_next)