diff options
Diffstat (limited to 'src')
63 files changed, 313 insertions, 313 deletions
diff --git a/src/actions.c b/src/actions.c index 9d1a415d1..91f072051 100644 --- a/src/actions.c +++ b/src/actions.c @@ -167,7 +167,7 @@ void common_unban(ChannelInfo * ci, char *nick) ircdproto->SendBanDel(ci->name, nick); } else { if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = ci->name; av[1] = buf; av[2] = "-b"; diff --git a/src/base64.c b/src/base64.c index 87212fa00..80022607b 100644 --- a/src/base64.c +++ b/src/base64.c @@ -184,7 +184,7 @@ int b64_decode(const char *src, char *target, size_t targsize) switch (state) { case 0: if (target) { - if ((size_t) tarindex >= targsize) + if (static_cast<size_t>(tarindex) >= targsize) return (-1); target[tarindex] = (pos - Base64) << 2; } @@ -192,7 +192,7 @@ int b64_decode(const char *src, char *target, size_t targsize) break; case 1: if (target) { - if ((size_t) tarindex + 1 >= targsize) + if (static_cast<size_t>(tarindex) + 1 >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 4; target[tarindex + 1] = ((pos - Base64) & 0x0f) @@ -203,7 +203,7 @@ int b64_decode(const char *src, char *target, size_t targsize) break; case 2: if (target) { - if ((size_t) tarindex + 1 >= targsize) + if (static_cast<size_t>(tarindex) + 1 >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 2; target[tarindex + 1] = ((pos - Base64) & 0x03) @@ -214,7 +214,7 @@ int b64_decode(const char *src, char *target, size_t targsize) break; case 3: if (target) { - if ((size_t) tarindex >= targsize) + if (static_cast<size_t>(tarindex) >= targsize) return (-1); target[tarindex] |= (pos - Base64); } @@ -290,13 +290,13 @@ const char* encode_ip(unsigned char *ip) if (!ip) return "*"; - if (strchr((char *) ip, ':')) { + if (strchr(reinterpret_cast<char *>(ip), ':')) { return NULL; } else { s_ip = str_signed(ip); ia.s_addr = inet_addr(s_ip); - cp = (unsigned char *) ia.s_addr; - b64_encode((char *) &cp, sizeof(struct in_addr), buf, 25); + cp = reinterpret_cast<unsigned char *>(ia.s_addr); + b64_encode(reinterpret_cast<char *>(&cp), sizeof(struct in_addr), buf, 25); } return buf; } @@ -308,7 +308,7 @@ int decode_ip(const char *buf) struct in_addr ia; b64_decode(buf, targ, 25); - ia = *(struct in_addr *) targ; + ia = *reinterpret_cast<struct in_addr *>(targ); if (len == 24) { /* IPv6 */ return 0; } else if (len == 8) /* IPv4 */ @@ -378,14 +378,14 @@ static char *int_to_base64(long val) static long base64_to_int(char *b64) { - int v = base64_to_int6_map[(unsigned char) *b64++]; + int v = base64_to_int6_map[static_cast<unsigned char>(*b64++)]; if (!b64) return 0; while (*b64) { v <<= 6; - v += base64_to_int6_map[(unsigned char) *b64++]; + v += base64_to_int6_map[static_cast<unsigned char>(*b64++)]; } return v; diff --git a/src/botserv.c b/src/botserv.c index 404c8cefc..6b0a1bbf4 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -694,7 +694,7 @@ void bot_join(ChannelInfo * ci) int ac; if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = ci->c->name; av[1] = buf; av[2] = "-b"; @@ -723,7 +723,7 @@ void bot_join(ChannelInfo * ci) /* Should we be invited? */ if ((ci->c->mode & anope_get_invite_mode()) - || (ci->c->limit && (unsigned int)ci->c->usercount >= ci->c->limit)) + || (ci->c->limit && ci->c->usercount >= ci->c->limit)) ircdproto->SendNoticeChanops(NULL, ci->c->name, "%s invited %s into the channel.", ci->bi->nick, ci->bi->nick); @@ -757,7 +757,7 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) get_idealban(ci, u, mask, sizeof(mask)); if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = ci->name; av[1] = buf; av[2] = "+b"; @@ -845,7 +845,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, get_idealban(ci, u, mask, sizeof(mask)); if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = ci->name; av[1] = buf; av[2] = "+b"; @@ -868,7 +868,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, kav[2] = ci->bi->nick; } else { if (strlen(reason) > 200) - *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX + (*const_cast<char **>(&reason))[200] = '\0'; // Unsafe cast -- will review later -- CyberBotX kav[2] = reason; } @@ -917,7 +917,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, av[2] = ci->bi->nick; } else { if (strlen(reason) > 200) - *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX + (*const_cast<char **>(&reason))[200] = '\0'; // Unsafe cast -- will review later -- CyberBotX av[2] = reason; } @@ -950,7 +950,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, if (!u || !is_on_chan(ci->c, u)) return; - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); if (ircd->protectedumode) { if (is_protected(u) && *mode == '-' && (requester != u)) { diff --git a/src/channels.c b/src/channels.c index 4d6f1a3c6..a91ae2b0f 100644 --- a/src/channels.c +++ b/src/channels.c @@ -182,7 +182,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, alog("debug: Removing instead of setting due to DEOPPED flag"); /* Swap adding and removing of the modes */ - for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX + for (s = const_cast<char *>(av[0]); *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX if (*s == '+') *s = '-'; else if (*s == '-') @@ -208,13 +208,13 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, continue; } - if (((int) mode) < 0) { + if (static_cast<int>(mode) < 0) { if (debug) alog("Debug: Malformed mode detected on %s.", chan->name); continue; } - if ((cum = &cumodes[(int) mode])->status != 0) { + if ((cum = &cumodes[static_cast<int>(mode)])->status != 0) { if (ac == 0) { alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); continue; @@ -262,7 +262,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, chan_remove_user_status(chan, user, cum->status); } - } else if ((cbm = &cbmodes[(int) mode])->flag != 0) { + } else if ((cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) { if (check >= 0) { if (add) chan->mode |= cbm->flag; @@ -288,7 +288,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, else chan->mode &= ~cbm->flag; } - } else if ((cmm = &cmmodes[(int) mode])->addmask) { + } else if ((cmm = &cmmodes[static_cast<int>(mode)])->addmask) { if (ac == 0) { alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); continue; @@ -374,13 +374,13 @@ Channel *findchan(const char *chan) while (c) { if (stricmp(c->name, chan) == 0) { if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, (void *) c); + alog("debug: findchan(%s) -> %p", chan, static_cast<void *>(c)); return c; } c = c->next; } if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, (void *) c); + alog("debug: findchan(%s) -> %p", chan, static_cast<void *>(c)); return NULL; } @@ -539,7 +539,7 @@ void do_join(const char *source, int ac, const char **av) return; } - t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX + t = const_cast<char *>(av[0]); // XXX Unsafe cast, this needs reviewing -- CyberBotX while (*(s = t)) { t = s + strcspn(s, ","); if (*t) @@ -576,7 +576,7 @@ void do_join(const char *source, int ac, const char **av) if (ac == 2) { if (debug) { alog("debug: recieved a new TS for JOIN: %ld", - (long int) ts); + static_cast<long>(ts)); } ts = strtoul(av[1], NULL, 10); } @@ -605,7 +605,7 @@ void do_kick(const char *source, int ac, const char **av) char *s, *t; struct u_chanlist *c; - t = (char *)av[1]; // XXX unsafe cast, this needs reviewing -- w00t + t = const_cast<char *>(av[1]); // XXX unsafe cast, this needs reviewing -- w00t while (*(s = t)) { t = s + strcspn(s, ","); if (*t) @@ -682,7 +682,7 @@ void do_part(const char *source, int ac, const char **av) } return; } - t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX + t = const_cast<char *>(av[0]); // XXX Unsafe cast, this needs reviewing -- CyberBotX while (*(s = t)) { t = s + strcspn(s, ","); if (*t) @@ -850,8 +850,8 @@ void do_sjoin(const char *source, int ac, const char **av) } } - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; + while (csmodes[static_cast<int>(*s)] != 0) + *end2++ = csmodes[static_cast<int>(*s++)]; *end2 = 0; @@ -936,8 +936,8 @@ void do_sjoin(const char *source, int ac, const char **av) end2 = cubuf + 1; - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; + while (csmodes[static_cast<int>(*s)] != 0) + *end2++ = csmodes[static_cast<int>(*s++)]; *end2 = 0; if (ircd->ts6) { @@ -1011,8 +1011,8 @@ void do_sjoin(const char *source, int ac, const char **av) end2 = cubuf + 1; - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; + while (csmodes[static_cast<int>(*s)] != 0) + *end2++ = csmodes[static_cast<int>(*s++)]; *end2 = 0; if (ircd->ts6) { @@ -1788,7 +1788,7 @@ char *get_limit(Channel * chan) if (chan->limit == 0) return NULL; - snprintf(limit, sizeof(limit), "%lu", (unsigned long int) chan->limit); + snprintf(limit, sizeof(limit), "%lu", static_cast<unsigned long>(chan->limit)); return limit; } diff --git a/src/chanserv.c b/src/chanserv.c index 944cd2e98..2751a24c1 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -387,17 +387,17 @@ void load_cs_dbase(void) for (j = 0; j < n_levels; j++) { SAFE(read_int16(&tmp16, f)); if (j < CA_SIZE) - ci->levels[j] = (int16) tmp16; + ci->levels[j] = static_cast<int16>(tmp16); } SAFE(read_int16(&ci->accesscount, f)); if (ci->accesscount) { - ci->access = (ChanAccess *)scalloc(ci->accesscount, sizeof(ChanAccess)); + ci->access = static_cast<ChanAccess *>(scalloc(ci->accesscount, sizeof(ChanAccess))); for (j = 0; j < ci->accesscount; j++) { SAFE(read_int16(&ci->access[j].in_use, f)); if (ci->access[j].in_use) { SAFE(read_int16(&tmp16, f)); - ci->access[j].level = (int16) tmp16; + ci->access[j].level = static_cast<int16>(tmp16); SAFE(read_string(&s, f)); if (s) { ci->access[j].nc = findcore(s); @@ -415,7 +415,7 @@ void load_cs_dbase(void) SAFE(read_int16(&ci->akickcount, f)); if (ci->akickcount) { - ci->akick = (AutoKick *)scalloc(ci->akickcount, sizeof(AutoKick)); + ci->akick = static_cast<AutoKick *>(scalloc(ci->akickcount, sizeof(AutoKick))); for (j = 0; j < ci->akickcount; j++) { SAFE(read_int16(&ci->akick[j].flags, f)); if (ci->akick[j].flags & AK_USED) { @@ -468,12 +468,12 @@ void load_cs_dbase(void) } SAFE(read_int16(&tmp16, f)); - ci->memos.memocount = (int16) tmp16; + ci->memos.memocount = static_cast<int16>(tmp16); SAFE(read_int16(&tmp16, f)); - ci->memos.memomax = (int16) tmp16; + ci->memos.memomax = static_cast<int16>(tmp16); if (ci->memos.memocount) { Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * ci->memos.memocount, 1); + memos = static_cast<Memo *>(scalloc(sizeof(Memo) * ci->memos.memocount, 1)); ci->memos.memos = memos; for (j = 0; j < ci->memos.memocount; j++, memos++) { SAFE(read_int32(&memos->number, f)); @@ -507,7 +507,7 @@ void load_cs_dbase(void) for (j = 0; j < n_ttb; j++) { SAFE(read_int16(&tmp16, f)); if (j < TTB_SIZE) - ci->ttb[j] = (int16) tmp16; + ci->ttb[j] = static_cast<int16>(tmp16); } for (j = n_ttb; j < TTB_SIZE; j++) ci->ttb[j] = 0; @@ -524,7 +524,7 @@ void load_cs_dbase(void) SAFE(read_int16(&ci->bwcount, f)); if (ci->bwcount) { - ci->badwords = (BadWord *)scalloc(ci->bwcount, sizeof(BadWord)); + ci->badwords = static_cast<BadWord *>(scalloc(ci->bwcount, sizeof(BadWord))); for (j = 0; j < ci->bwcount; j++) { SAFE(read_int16(&ci->badwords[j].in_use, f)); if (ci->badwords[j].in_use) { @@ -791,7 +791,7 @@ void check_modes(Channel * c) else value = cbmi->csgetvalue(ci); - cbm = &cbmodes[(int) cbmi->mode]; + cbm = &cbmodes[static_cast<int>(cbmi->mode)]; cbm->setvalue(c, value); if (value) { @@ -817,7 +817,7 @@ void check_modes(Channel * c) if (value && csvalue && strcmp(value, csvalue)) { *end++ = cbmi->mode; - cbm = &cbmodes[(int) cbmi->mode]; + cbm = &cbmodes[static_cast<int>(cbmi->mode)]; cbm->setvalue(c, csvalue); *end2++ = ' '; @@ -845,7 +845,7 @@ void check_modes(Channel * c) /* Add the eventual parameter and clean up the Channel structure */ if (cbmi->getvalue) { - cbm = &cbmodes[(int) cbmi->mode]; + cbm = &cbmodes[static_cast<int>(cbmi->mode)]; if (!(cbm->flags & CBM_MINUS_NO_ARG)) { char *value = cbmi->getvalue(c); @@ -1102,14 +1102,14 @@ int check_should_protect(User * user, char *chan) static void timeout_leave(Timeout * to) { - const char *chan = (const char *)to->data; + const char *chan = static_cast<const char *>(to->data); ChannelInfo *ci = cs_findchan(chan); if (ci) /* Check cos the channel may be dropped in the meantime */ ci->flags &= ~CI_INHABIT; ircdproto->SendPart(findbot(s_ChanServ), chan, NULL); - delete [] (const char *)to->data; + delete [] static_cast<const char *>(to->data); } @@ -1228,7 +1228,7 @@ int check_kick(User * user, const char *chan, time_t chants) if (c) { if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = chan; av[1] = buf; av[2] = "+b"; @@ -1507,7 +1507,7 @@ ChannelInfo *cs_findchan(const char *chan) return NULL; } - for (ci = chanlists[(unsigned char) tolower(chan[1])]; ci; + for (ci = chanlists[static_cast<unsigned char>(tolower(chan[1]))]; ci; ci = ci->next) { if (stricmp(ci->name, chan) == 0) return ci; @@ -1572,13 +1572,13 @@ void alpha_insert_chan(ChannelInfo * ci) chan = ci->name; - for (prev = NULL, ptr = chanlists[(unsigned char) tolower(chan[1])]; + for (prev = NULL, ptr = chanlists[static_cast<unsigned char>(tolower(chan[1]))]; ptr != NULL && stricmp(ptr->name, chan) < 0; prev = ptr, ptr = ptr->next); ci->prev = prev; ci->next = ptr; if (!prev) - chanlists[(unsigned char) tolower(chan[1])] = ci; + chanlists[static_cast<unsigned char>(tolower(chan[1]))] = ci; else prev->next = ci; if (ptr) @@ -1682,7 +1682,7 @@ int delchan(ChannelInfo * ci) if (ci->prev) ci->prev->next = ci->next; else - chanlists[(unsigned char) tolower(ci->name[1])] = ci->next; + chanlists[static_cast<unsigned char>(tolower(ci->name[1]))] = ci->next; if (ci->desc) delete [] ci->desc; if (ci->url) @@ -1994,7 +1994,7 @@ char *cs_get_limit(ChannelInfo * ci) return NULL; snprintf(limit, sizeof(limit), "%lu", - (unsigned long int) ci->mlock_limit); + static_cast<unsigned long>(ci->mlock_limit)); return limit; } diff --git a/src/config.c b/src/config.c index 8846ebf39..ea3bea1c1 100644 --- a/src/config.c +++ b/src/config.c @@ -1627,7 +1627,7 @@ int read_config(int reload) if (s) { RootNumber++; ServicesRoots = - (char **)realloc(ServicesRoots, sizeof(char *) * RootNumber); + static_cast<char **>(realloc(ServicesRoots, sizeof(char *) * RootNumber)); ServicesRoots[RootNumber - 1] = sstrdup(s); } } while ((s = strtok(NULL, " "))); @@ -1647,7 +1647,7 @@ int read_config(int reload) do { if (s) { NumUlines++; - Ulines = (char **)realloc(Ulines, sizeof(char *) * NumUlines); + Ulines = static_cast<char **>(realloc(Ulines, sizeof(char *) * NumUlines)); Ulines[NumUlines - 1] = sstrdup(s); } } while ((s = strtok(NULL, " "))); diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index 15e7c15ef..3fce1698e 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -118,7 +118,7 @@ int do_badwords(User * u) if (i < BSBadWordsMax) { ci->bwcount++; ci->badwords = - (BadWord *)srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); + static_cast<BadWord *>(srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount)); } else { notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, BSBadWordsMax); @@ -211,7 +211,7 @@ int do_badwords(User * u) ci->bwcount--; } ci->badwords = - (BadWord *)srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount); + static_cast<BadWord *>(srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount)); } } else if (stricmp(cmd, "LIST") == 0) { diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index 229b4dba2..55d230710 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -95,7 +95,7 @@ int do_kickcmd(User * u) if (!stricmp(value, "ON")) { if (ttb) { ci->ttb[TTB_BADWORDS] = - strtol(ttb, (char **) NULL, 10); + strtol(ttb, NULL, 10); /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) { @@ -124,7 +124,7 @@ int do_kickcmd(User * u) } else if (!stricmp(option, "BOLDS")) { if (!stricmp(value, "ON")) { if (ttb) { - ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10); + ci->ttb[TTB_BOLDS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) { if (debug) { @@ -152,7 +152,7 @@ int do_kickcmd(User * u) char *percent = strtok(NULL, " "); if (ttb) { - ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10); + ci->ttb[TTB_CAPS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) { if (debug) { @@ -194,7 +194,7 @@ int do_kickcmd(User * u) } else if (!stricmp(option, "COLORS")) { if (!stricmp(value, "ON")) { if (ttb) { - ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10); + ci->ttb[TTB_COLORS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_COLORS] < 0) { if (debug) { @@ -222,7 +222,7 @@ int do_kickcmd(User * u) char *secs = strtok(NULL, " "); if (ttb) { - ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10); + ci->ttb[TTB_FLOOD] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) { if (debug) { @@ -266,7 +266,7 @@ int do_kickcmd(User * u) char *times = strtok(NULL, " "); if (ttb) { - ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10); + ci->ttb[TTB_REPEAT] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) { if (debug) { @@ -301,7 +301,7 @@ int do_kickcmd(User * u) if (!stricmp(value, "ON")) { if (ttb) { ci->ttb[TTB_REVERSES] = - strtol(ttb, (char **) NULL, 10); + strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) { if (debug) { @@ -327,7 +327,7 @@ int do_kickcmd(User * u) if (!stricmp(value, "ON")) { if (ttb) { ci->ttb[TTB_UNDERLINES] = - strtol(ttb, (char **) NULL, 10); + strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) { if (debug) { diff --git a/src/core/cs_access.c b/src/core/cs_access.c index 486c482e4..604761d82 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -232,8 +232,8 @@ int do_access(User * u) if (i < CSAccessMax) { ci->accesscount++; ci->access = - (ChanAccess *)srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); + static_cast<ChanAccess *>(srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount)); } else { notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, CSAccessMax); @@ -346,7 +346,7 @@ int do_access(User * u) ci->accesscount--; } ci->access = - (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); + static_cast<ChanAccess *>(srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount)); /* We don't know the nick if someone used numbers, so we trigger the event without * nick param. We just do this once, even if someone enters a range. -Certus */ diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index df4bd69f5..cc90381d9 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -299,7 +299,7 @@ int do_akick(User * u) } ci->akickcount++; ci->akick = - (AutoKick *)srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount); + static_cast<AutoKick *>(srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount)); akick = &ci->akick[i]; akick->flags = AK_USED; if (nc) { @@ -518,7 +518,7 @@ int do_akick(User * u) ci->akickcount--; } ci->akick = - (AutoKick *)srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount); + static_cast<AutoKick *>(srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount)); } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index 4f8db1fd0..77e1b0b9b 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -68,7 +68,7 @@ int do_ban(User * u) int is_same; if (!reason) { - reason = (char *)"Requested"; // XXX unsafe cast -- w00t + reason = const_cast<char *>("Requested"); // XXX unsafe cast -- w00t } else { if (strlen(reason) > 200) reason[200] = '\0'; diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 3d2e13fdf..683468f58 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -185,7 +185,7 @@ int do_clear(User * u) ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[1] = buf; av[2] = tmp; /* We have to give as much nicks as modes.. - Viper */ @@ -221,7 +221,7 @@ int do_clear(User * u) (isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : "")); if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[1] = buf; av[2] = tmp; /* We have to give as much nicks as modes.. - Viper */ @@ -256,7 +256,7 @@ int do_clear(User * u) continue; if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); av[0] = chan; av[1] = buf; av[2] = "-h"; @@ -300,7 +300,7 @@ int do_clear(User * u) continue; if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long int>(time(NULL))); av[0] = chan; av[1] = buf; av[2] = "-v"; diff --git a/src/core/cs_set.c b/src/core/cs_set.c index f6ed8611b..2861222fa 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -56,7 +56,7 @@ class CSSet : public Module c = createCommand("SET FOUNDER", NULL, NULL, CHAN_HELP_SET_FOUNDER, -1, -1, -1, -1); this->AddCommand(CHANSERV, c, MOD_UNIQUE); c = createCommand("SET SUCCESSOR", NULL, NULL, CHAN_HELP_SET_SUCCESSOR, -1, -1, -1, -1); - c->help_param1 = (char *) (long) CSMaxReg; + c->help_param1 = reinterpret_cast<char *>(static_cast<long>(CSMaxReg)); this->AddCommand(CHANSERV, c, MOD_UNIQUE); c = createCommand("SET PASSWORD", NULL, NULL, CHAN_HELP_SET_PASSWORD, -1, -1, -1, -1); this->AddCommand(CHANSERV, c, MOD_UNIQUE); @@ -470,7 +470,7 @@ int do_set_mlock(User * u, ChannelInfo * ci, char *param) continue; } - if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { + if (static_cast<int>(mode) < 128 && (cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) { if ((cbm->flags & CBM_NO_MLOCK) || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) { notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index a757f7968..e7d73d5c7 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -301,8 +301,8 @@ int do_xop(User * u, const char *xname, int xlev, int *xmsgs) if (i < CSAccessMax) { ci->accesscount++; ci->access = - (ChanAccess *)srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); + static_cast<ChanAccess *>(srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount)); } else { notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, CSAccessMax); @@ -434,7 +434,7 @@ int do_xop(User * u, const char *xname, int xlev, int *xmsgs) ci->accesscount--; } ci->access = - (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); + static_cast<ChanAccess *>(srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount)); } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c index c950afe60..ea6b35e62 100644 --- a/src/core/hs_delall.c +++ b/src/core/hs_delall.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -72,7 +72,7 @@ int do_delall(User * u) } nc = na->nc; for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); delHostCore(na->nick); } alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick); diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c index 10555d7b7..1e865cb58 100644 --- a/src/core/hs_setall.c +++ b/src/core/hs_setall.c @@ -57,7 +57,7 @@ void myHostServHelp(User * u) **/ int do_setall(User * u) { - char *nick = (char *)strtok(NULL, " "); + char *nick = strtok(NULL, " "); char *rawhostmask = strtok(NULL, " "); char *hostmask = new char[HOSTMAX]; diff --git a/src/core/ms_set.c b/src/core/ms_set.c index a4aebd3e0..f3d00bf8d 100644 --- a/src/core/ms_set.c +++ b/src/core/ms_set.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -38,7 +38,7 @@ class MSSet : public Module this->AddCommand(MEMOSERV, c, MOD_UNIQUE); c = createCommand("SET LIMIT", NULL, NULL, -1, MEMO_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT); - c->help_param1 = (char *) (long) MSMaxMemos; + c->help_param1 = reinterpret_cast<char *>(static_cast<long>(MSMaxMemos)); this->AddCommand(MEMOSERV, c, MOD_UNIQUE); moduleSetMemoHelp(myMemoServHelp); diff --git a/src/core/ns_access.c b/src/core/ns_access.c index c4409928d..7fb6ab79b 100644 --- a/src/core/ns_access.c +++ b/src/core/ns_access.c @@ -125,7 +125,7 @@ int do_access(User * u) na->nc->accesscount++; na->nc->access = - (char **)srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount); + static_cast<char **>(srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount)); na->nc->access[na->nc->accesscount - 1] = sstrdup(mask); notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask); @@ -149,8 +149,8 @@ int do_access(User * u) (na->nc->accesscount - i) * sizeof(char *)); if (na->nc->accesscount) /* if there are any entries left... */ na->nc->access = - (char **)srealloc(na->nc->access, - na->nc->accesscount * sizeof(char *)); + static_cast<char **>(srealloc(na->nc->access, + na->nc->accesscount * sizeof(char *))); else { free(na->nc->access); na->nc->access = NULL; diff --git a/src/core/ns_group.c b/src/core/ns_group.c index c40d961ac..10cb9fee8 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -104,14 +104,14 @@ int do_group(User * u) return MOD_CONT; } } - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { + for (i = 0; i < servadmins.count && (nc = static_cast<NickCore *>(servadmins.list[i])); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { + for (i = 0; i < servopers.count && (nc = static_cast<NickCore *>(servopers.list[i])); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); @@ -182,7 +182,7 @@ int do_group(User * u) common_get_vhost(u)); na->last_realname = sstrdup(u->realname); na->time_registered = na->last_seen = time(NULL); - na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); + na->status = static_cast<int16>(NS_IDENTIFIED | NS_RECOGNIZED); if (!(na->nc->flags & NI_SERVICES_ROOT)) { for (i = 0; i < RootNumber; i++) { @@ -202,7 +202,7 @@ int do_group(User * u) u->lastnickreg = time(NULL); snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); + static_cast<unsigned long>(u->timestamp)); if (ircd->modeonreg) { len = strlen(ircd->modeonreg); strncpy(modes,ircd->modeonreg,512); @@ -282,7 +282,7 @@ int do_glist(User * u) nick ? NICK_GLIST_HEADER_X : NICK_GLIST_HEADER, na->nc->display); for (i = 0; i < na->nc->aliases.count; i++) { - na2 = (NickAlias *)na->nc->aliases.list[i]; + na2 = static_cast<NickAlias *>(na->nc->aliases.list[i]); if (na2->nc == na->nc) { if (!(wont_expire = na2->status & NS_NO_EXPIRE)) { expt = na2->last_seen + NSExpire; diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index ee328ef19..19fc791bf 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -105,7 +105,7 @@ int do_identify(User * u) na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); + static_cast<unsigned long>(u->timestamp)); if (ircd->modeonreg) { len = strlen(ircd->modeonreg); diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 692c21531..bb2e2d741 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -133,14 +133,14 @@ int do_register(User * u) return MOD_CONT; } } - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { + for (i = 0; i < servadmins.count && (nc = static_cast<NickCore *>(servadmins.list[i])); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { + for (i = 0; i < servopers.count && (nc = static_cast<NickCore *>(servopers.list[i])); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); @@ -180,7 +180,7 @@ int do_register(User * u) for (idx = 0; idx < 9; idx++) { passcode[idx] = chars[(1 + - (int) (((float) (max - min)) * getrandom16() / + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / (65535 + 1.0)) + min)]; } passcode[idx] = '\0'; nr = makerequest(u->nick); @@ -301,7 +301,7 @@ int do_confirm(User * u) char tmp_pass[PASSMAX]; memcpy(na->nc->pass, nr->password, PASSMAX); - na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); + na->status = static_cast<int16>(NS_IDENTIFIED | NS_RECOGNIZED); /* na->nc->flags |= NI_ENCRYPTEDPW; */ na->nc->flags |= NSDefFlags; @@ -326,7 +326,7 @@ int do_confirm(User * u) na->time_registered = na->last_seen = time(NULL); if (NSAddAccessOnReg) { na->nc->accesscount = 1; - na->nc->access = (char **)scalloc(sizeof(char *), 1); + na->nc->access = static_cast<char **>(scalloc(sizeof(char *), 1)); na->nc->access[0] = create_mask(u); } else { na->nc->accesscount = 0; @@ -365,7 +365,7 @@ int do_confirm(User * u) if (ircd->tsonmode) { snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); + static_cast<unsigned long>(u->timestamp)); common_svsmode(u, modes, tsbuf); } else { common_svsmode(u, modes, NULL); diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c index 54fb2fc0f..4bc2eab66 100644 --- a/src/core/ns_saset.c +++ b/src/core/ns_saset.c @@ -170,7 +170,7 @@ int do_saset_display(User * u, NickCore * nc, char *param) /* First check whether param is a valid nick of the group */ for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); if (stricmp(na->nick, param) == 0) { param = na->nick; /* Because case may differ */ break; diff --git a/src/core/ns_set.c b/src/core/ns_set.c index 4267f46b2..221743603 100644 --- a/src/core/ns_set.c +++ b/src/core/ns_set.c @@ -154,7 +154,7 @@ int do_set_display(User * u, NickCore * nc, char *param) /* First check whether param is a valid nick of the group */ for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); if (!stricmp(na->nick, param)) { param = na->nick; /* Because case may differ */ break; diff --git a/src/core/os_admin.c b/src/core/os_admin.c index d7e8c3c75..21905e3b5 100644 --- a/src/core/os_admin.c +++ b/src/core/os_admin.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -154,7 +154,7 @@ int do_admin(User * u) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else if (!stricmp(cmd, "LIST")) { int sent_header = 0; - + if (servadmins.count == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); return MOD_CONT; @@ -176,11 +176,11 @@ int do_admin(User * u) for (i = 0; i < servadmins.count; i++) if (!stricmp - (nick, ((NickCore *) servadmins.list[i])->display) + (nick, (static_cast<NickCore *>(servadmins.list[i]))->display) || match_wild_nocase(nick, - ((NickCore *) servadmins. - list[i])->display)) - admin_list(i + 1, (NickCore *)servadmins.list[i], u, &sent_header); + (static_cast<NickCore *>(servadmins. + list[i]))->display)) + admin_list(i + 1, static_cast<NickCore *>(servadmins.list[i]), u, &sent_header); if (!sent_header) notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); @@ -213,7 +213,7 @@ int admin_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return admin_list(number, (NickCore *)item, u, sent_header); + return admin_list(number, static_cast<NickCore *>(item), u, sent_header); } int admin_list(int number, NickCore * nc, User * u, int *sent_header) diff --git a/src/core/os_akill.c b/src/core/os_akill.c index a85c50cb1..c2c6a2d64 100644 --- a/src/core/os_akill.c +++ b/src/core/os_akill.c @@ -249,11 +249,11 @@ int do_akill(User * u) for (i = 0; i < akills.count; i++) { snprintf(amask, sizeof(amask), "%s@%s", - ((Akill *) akills.list[i])->user, - ((Akill *) akills.list[i])->host); + (static_cast<Akill *>(akills.list[i]))->user, + (static_cast<Akill *>(akills.list[i]))->host); if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - akill_list(i + 1, (Akill *)akills.list[i], u, &sent_header); + akill_list(i + 1, static_cast<Akill *>(akills.list[i]), u, &sent_header); } if (!sent_header) @@ -288,11 +288,11 @@ int do_akill(User * u) for (i = 0; i < akills.count; i++) { snprintf(amask, sizeof(amask), "%s@%s", - ((Akill *) akills.list[i])->user, - ((Akill *) akills.list[i])->host); + (static_cast<Akill *>(akills.list[i]))->user, + (static_cast<Akill *>(akills.list[i]))->host); if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - akill_view(i + 1, (Akill *)akills.list[i], u, &sent_header); + akill_view(i + 1, static_cast<Akill *>(akills.list[i]), u, &sent_header); } if (!sent_header) @@ -340,7 +340,7 @@ int akill_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return akill_list(number, (Akill *)item, u, sent_header); + return akill_list(number, static_cast<Akill *>(item), u, sent_header); } /* Callback for enumeration purposes */ @@ -351,7 +351,7 @@ int akill_view_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return akill_view(number, (Akill *)item, u, sent_header); + return akill_view(number, static_cast<Akill *>(item), u, sent_header); } /* Lists an AKILL entry, prefixing it with the header if needed */ diff --git a/src/core/os_oper.c b/src/core/os_oper.c index f93dab779..6586ceae7 100644 --- a/src/core/os_oper.c +++ b/src/core/os_oper.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -154,7 +154,7 @@ int do_oper(User * u) notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } - + if (servopers.count == 0) { notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY); return MOD_CONT; @@ -176,11 +176,11 @@ int do_oper(User * u) for (i = 0; i < servopers.count; i++) if (!stricmp - (nick, ((NickCore *) servopers.list[i])->display) + (nick, (static_cast<NickCore *>(servopers.list[i]))->display) || match_wild_nocase(nick, - ((NickCore *) servopers.list[i])-> + (static_cast<NickCore *>(servopers.list[i]))-> display)) - oper_list(i + 1, (NickCore *)servopers.list[i], u, &sent_header); + oper_list(i + 1, static_cast<NickCore *>(servopers.list[i]), u, &sent_header); if (!sent_header) notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); @@ -230,7 +230,7 @@ int oper_list_callback(SList * slist, int number, void *item, va_list args) User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return oper_list(number, (NickCore *)item, u, sent_header); + return oper_list(number, static_cast<NickCore *>(item), u, sent_header); } MODULE_INIT("os_oper", OSOper) diff --git a/src/core/os_quit.c b/src/core/os_quit.c index a06bb6966..9ae6b05be 100644 --- a/src/core/os_quit.c +++ b/src/core/os_quit.c @@ -59,7 +59,7 @@ int do_os_quit(User * u) if (!quitmsg) quitmsg = "QUIT command received, but out of memory!"; else - sprintf((char *)quitmsg, "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. + sprintf(const_cast<char *>(quitmsg), "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. if (GlobalOnCycle) { oper_global(NULL, "%s", GlobalOnCycleMessage); diff --git a/src/core/os_reload.c b/src/core/os_reload.c index 9e4495ec4..e31c1207c 100644 --- a/src/core/os_reload.c +++ b/src/core/os_reload.c @@ -61,7 +61,7 @@ int do_reload(User * u) quitmsg = "Error during the reload of the configuration file, but out of memory!"; else - sprintf((char *)quitmsg, /* XXX */ + sprintf(const_cast<char *>(quitmsg), /* XXX */ "Error during the reload of the configuration file!"); quitting = 1; } diff --git a/src/core/os_restart.c b/src/core/os_restart.c index fe0f8ddb7..537db5d3a 100644 --- a/src/core/os_restart.c +++ b/src/core/os_restart.c @@ -64,7 +64,7 @@ int do_restart(User * u) if (!quitmsg) quitmsg = "RESTART command received, but out of memory!"; else - sprintf((char *)quitmsg, /* XXX */ "RESTART command received from %s", u->nick); + sprintf(const_cast<char *>(quitmsg), /* XXX */ "RESTART command received from %s", u->nick); if (GlobalOnCycle) { oper_global(NULL, "%s", GlobalOnCycleMessage); diff --git a/src/core/os_sgline.c b/src/core/os_sgline.c index 49aa459fe..934a8abf5 100644 --- a/src/core/os_sgline.c +++ b/src/core/os_sgline.c @@ -229,10 +229,10 @@ int do_sgline(User * u) char *amask; for (i = 0; i < sglines.count; i++) { - amask = ((SXLine *) sglines.list[i])->mask; + amask = (static_cast<SXLine *>(sglines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - sgline_list(i + 1, (SXLine *)sglines.list[i], u, &sent_header); + sgline_list(i + 1, static_cast<SXLine *>(sglines.list[i]), u, &sent_header); } if (!sent_header) @@ -266,10 +266,10 @@ int do_sgline(User * u) char *amask; for (i = 0; i < sglines.count; i++) { - amask = ((SXLine *) sglines.list[i])->mask; + amask = (static_cast<SXLine *>(sglines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - sgline_view(i + 1, (SXLine *)sglines.list[i], u, &sent_header); + sgline_view(i + 1, static_cast<SXLine *>(sglines.list[i]), u, &sent_header); } if (!sent_header) @@ -317,7 +317,7 @@ int sgline_view_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return sgline_view(number, (SXLine *)item, u, sent_header); + return sgline_view(number, static_cast<SXLine *>(item), u, sent_header); } /* Lists an SGLINE entry, prefixing it with the header if needed */ @@ -346,7 +346,7 @@ int sgline_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return sgline_list(number, (SXLine *)item, u, sent_header); + return sgline_list(number, static_cast<SXLine *>(item), u, sent_header); } MODULE_INIT("os_sgline", OSSGLine) diff --git a/src/core/os_shutdown.c b/src/core/os_shutdown.c index 32ab16141..5fa4080a6 100644 --- a/src/core/os_shutdown.c +++ b/src/core/os_shutdown.c @@ -59,7 +59,7 @@ int do_shutdown(User * u) if (!quitmsg) quitmsg = "SHUTDOWN command received, but out of memory!"; else - sprintf((char *)quitmsg, /* XXX */ "SHUTDOWN command received from %s", u->nick); + sprintf(const_cast<char *>(quitmsg), /* XXX */ "SHUTDOWN command received from %s", u->nick); if (GlobalOnCycle) { oper_global(NULL, "%s", GlobalOnCycleMessage); diff --git a/src/core/os_sqline.c b/src/core/os_sqline.c index 072c224f8..822334f36 100644 --- a/src/core/os_sqline.c +++ b/src/core/os_sqline.c @@ -224,10 +224,10 @@ int do_sqline(User * u) char *amask; for (i = 0; i < sqlines.count; i++) { - amask = ((SXLine *) sqlines.list[i])->mask; + amask = (static_cast<SXLine *>(sqlines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - sqline_list(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); + sqline_list(i + 1, static_cast<SXLine *>(sqlines.list[i]), u, &sent_header); } if (!sent_header) @@ -261,10 +261,10 @@ int do_sqline(User * u) char *amask; for (i = 0; i < sqlines.count; i++) { - amask = ((SXLine *) sqlines.list[i])->mask; + amask = (static_cast<SXLine *>(sqlines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - sqline_view(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); + sqline_view(i + 1, static_cast<SXLine *>(sqlines.list[i]), u, &sent_header); } if (!sent_header) @@ -310,7 +310,7 @@ int sqline_view_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return sqline_view(number, (SXLine *)item, u, sent_header); + return sqline_view(number, static_cast<SXLine *>(item), u, sent_header); } /* Lists an SQLINE entry, prefixing it with the header if needed */ @@ -339,7 +339,7 @@ int sqline_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return sqline_list(number, (SXLine *)item, u, sent_header); + return sqline_list(number, static_cast<SXLine *>(item), u, sent_header); } MODULE_INIT("os_sqline", OSSQLine) diff --git a/src/core/os_staff.c b/src/core/os_staff.c index 9e5b820b4..c5a58121e 100644 --- a/src/core/os_staff.c +++ b/src/core/os_staff.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -75,7 +75,7 @@ int do_staff(User * u) ServicesRoots[idx]); } else if ((nc = findcore(ServicesRoots[idx]))) { for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); if ((au = finduser(na->nick))) { /* see if user is online */ found = 1; notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, @@ -102,7 +102,7 @@ int opers_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); char *level = va_arg(args, char *); - return opers_list(number, (NickCore *)item, u, level); + return opers_list(number, static_cast<NickCore *>(item), u, level); } @@ -126,7 +126,7 @@ int opers_list(int number, NickCore * nc, User * u, char *level) nc->display); } else { for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); if ((au = finduser(na->nick))) { /* see if user is online */ found = 1; notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level, diff --git a/src/core/os_stats.c b/src/core/os_stats.c index 35a0f03f7..d4dc8b085 100644 --- a/src/core/os_stats.c +++ b/src/core/os_stats.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -382,7 +382,7 @@ void get_operserv_stats(long *nrec, long *memuse) mem += akills.count * sizeof(Akill); for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; + ak = static_cast<Akill *>(akills.list[i]); mem += strlen(ak->user) + 1; mem += strlen(ak->host) + 1; mem += strlen(ak->by) + 1; @@ -395,7 +395,7 @@ void get_operserv_stats(long *nrec, long *memuse) mem += sglines.count * sizeof(SXLine); for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; + sx = static_cast<SXLine *>(sglines.list[i]); mem += strlen(sx->mask) + 1; mem += strlen(sx->by) + 1; mem += strlen(sx->reason) + 1; @@ -407,7 +407,7 @@ void get_operserv_stats(long *nrec, long *memuse) mem += sqlines.count * sizeof(SXLine); for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; + sx = static_cast<SXLine *>(sqlines.list[i]); mem += strlen(sx->mask) + 1; mem += strlen(sx->by) + 1; mem += strlen(sx->reason) + 1; @@ -419,7 +419,7 @@ void get_operserv_stats(long *nrec, long *memuse) mem += szlines.count * sizeof(SXLine); for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; + sx = static_cast<SXLine *>(szlines.list[i]); mem += strlen(sx->mask) + 1; mem += strlen(sx->by) + 1; mem += strlen(sx->reason) + 1; diff --git a/src/core/os_szline.c b/src/core/os_szline.c index 4e324b261..b9181c135 100644 --- a/src/core/os_szline.c +++ b/src/core/os_szline.c @@ -221,10 +221,10 @@ int do_szline(User * u) char *amask; for (i = 0; i < szlines.count; i++) { - amask = ((SXLine *) szlines.list[i])->mask; + amask = (static_cast<SXLine *>(szlines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - szline_list(i + 1, (SXLine *)szlines.list[i], u, &sent_header); + szline_list(i + 1, static_cast<SXLine *>(szlines.list[i]), u, &sent_header); } if (!sent_header) @@ -255,10 +255,10 @@ int do_szline(User * u) char *amask; for (i = 0; i < szlines.count; i++) { - amask = ((SXLine *) szlines.list[i])->mask; + amask = (static_cast<SXLine *>(szlines.list[i]))->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) - szline_view(i + 1, (SXLine *)szlines.list[i], u, &sent_header); + szline_view(i + 1, static_cast<SXLine *>(szlines.list[i]), u, &sent_header); } if (!sent_header) @@ -305,7 +305,7 @@ int szline_view_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return szline_view(number, (SXLine *)item, u, sent_header); + return szline_view(number, static_cast<SXLine *>(item), u, sent_header); } /* Callback for enumeration purposes */ @@ -316,7 +316,7 @@ int szline_list_callback(SList * slist, int number, void *item, User *u = va_arg(args, User *); int *sent_header = va_arg(args, int *); - return szline_list(number, (SXLine *)item, u, sent_header); + return szline_list(number, static_cast<SXLine *>(item), u, sent_header); } /* Lists an SZLINE entry, prefixing it with the header if needed */ diff --git a/src/datafiles.c b/src/datafiles.c index d14e47343..541ad9ca5 100644 --- a/src/datafiles.c +++ b/src/datafiles.c @@ -466,7 +466,7 @@ int read_ptr(void **ret, dbFILE * f) c = fgetc(f->fp); if (c == EOF) return -1; - *ret = (c ? (void *) 1 : (void *) 0); + *ret = (c ? reinterpret_cast<void *>(1) : reinterpret_cast<void *>(0)); return 0; } @@ -533,7 +533,7 @@ int write_string(const char *s, dbFILE * f) len = strlen(s); if (len > 65534) len = 65534; - if (write_int16((uint16) (len + 1), f) < 0) + if (write_int16(static_cast<uint16>(len + 1), f) < 0) return -1; if (len > 0 && fwrite(s, 1, len, f->fp) != len) return -1; diff --git a/src/events.c b/src/events.c index 1804f9260..ce36aa3e2 100644 --- a/src/events.c +++ b/src/events.c @@ -91,7 +91,7 @@ int displayEventHook(EvtHook * evh) int i = 0; alog("Displaying message list for %s", evh->name); for (msg = evh; msg; msg = msg->next) { - alog("%d: 0x%p", ++i, (void *) msg); + alog("%d: 0x%p", ++i, static_cast<void *>(msg)); } alog("end"); return 0; @@ -199,7 +199,7 @@ int addEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh) current->evh = evh; if (debug) alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) evh->next, (void *) evh); + static_cast<void *>(evh->next), static_cast<void *>(evh)); return MOD_ERR_OK; } lastHash = current; diff --git a/src/hostserv.c b/src/hostserv.c index 93515fb04..bcfde7d53 100644 --- a/src/hostserv.c +++ b/src/hostserv.c @@ -469,7 +469,7 @@ int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, char *creator, NickAlias *na; for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); addHostCore(na->nick, vIdent, hostmask, creator, time); } return MOD_CONT; @@ -517,7 +517,7 @@ int is_host_setter(User * u) /* Look through all user's aliases (0000412) */ for (i = 0; i < u->na->nc->aliases.count; i++) { - na = (NickAlias *)u->na->nc->aliases.list[i]; + na = static_cast<NickAlias *>(u->na->nc->aliases.list[i]); for (j = 0; j < HostNumber; j++) { if (stricmp(HostSetters[j], na->nick) == 0) { return 1; diff --git a/src/init.c b/src/init.c index d6122fa3e..ac1837fb9 100644 --- a/src/init.c +++ b/src/init.c @@ -317,7 +317,7 @@ static void write_pidfile(void) pidfile = fopen(PIDFilename, "w"); if (pidfile) { - fprintf(pidfile, "%d\n", (int) getpid()); + fprintf(pidfile, "%d\n", static_cast<int>(getpid())); fclose(pidfile); atexit(remove_pidfile); } else { @@ -134,7 +134,7 @@ char *log_gettimestamp(void) strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); s = tbuf + strlen(tbuf); s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", - (int) tv.tv_usec); + static_cast<int>(tv.tv_usec)); strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); } else { #endif diff --git a/src/main.c b/src/main.c index 59c63c1fc..53bebd298 100644 --- a/src/main.c +++ b/src/main.c @@ -418,7 +418,7 @@ void sighandler(int signum) !(quitmsg = new char[BUFSIZE])) { quitmsg = "Out of memory!"; } else { - snprintf((char *)quitmsg, BUFSIZE, "Services terminating on signal %d", signum); + snprintf(const_cast<char *>(quitmsg), BUFSIZE, "Services terminating on signal %d", signum); } if (signum == SIGSEGV) { @@ -554,7 +554,7 @@ int main(int ac, char **av, char **envp) waiting = 1; /* this is a nasty nasty typecast. we need to rewrite the socket stuff -Certus */ - i = (int) (long) sgets2(inbuf, sizeof(inbuf), servsock); + i = static_cast<int>(reinterpret_cast<long>(sgets2(inbuf, sizeof(inbuf), servsock))); waiting = 0; if ((i > 0) || (i < (-1))) { process(); @@ -563,7 +563,7 @@ int main(int ac, char **av, char **envp) quitmsg = new char[BUFSIZE]; if (quitmsg) { // Naughty, but oh well. :) - snprintf((char *)quitmsg, BUFSIZE, + snprintf(const_cast<char *>(quitmsg), BUFSIZE, "Read error from server: %s (error num: %d)", strerror(errno_save), errno_save); } else { diff --git a/src/memoserv.c b/src/memoserv.c index 35c433e4d..df970565e 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -253,7 +253,7 @@ void memo_send(User * u, char *name, char *text, int z) } else { u->lastmemosend = now; mi->memocount++; - mi->memos = (Memo *)srealloc(mi->memos, sizeof(Memo) * mi->memocount); + mi->memos = static_cast<Memo *>(srealloc(mi->memos, sizeof(Memo) * mi->memocount)); m = &mi->memos[mi->memocount - 1]; strscpy(m->sender, source, NICKMAX); if (mi->memocount > 1) { @@ -289,7 +289,7 @@ void memo_send(User * u, char *name, char *text, int z) int i; for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; + na = static_cast<NickAlias *>(nc->aliases.list[i]); if (na->u && nick_identified(na->u)) notice_lang(s_MemoServ, na->u, MEMO_NEW_MEMO_ARRIVED, source, diff --git a/src/messages.c b/src/messages.c index 4f82d96df..81f3d02c0 100644 --- a/src/messages.c +++ b/src/messages.c @@ -133,7 +133,7 @@ int m_privmsg(const char *source, const char *receiver, const char *msg) if (s_BotServ && (ci = cs_findchan(receiver))) { /* Some paranoia checks */ if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) { - botchanmsgs(u, ci, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + botchanmsgs(u, ci, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } } } else { @@ -173,25 +173,25 @@ int m_privmsg(const char *source, const char *receiver, const char *msg) s_OperServ, u->nick, u->username, u->host); } else { - operserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + operserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } } else if (!stricmp(receiver, s_NickServ)) { - nickserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + nickserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (!stricmp(receiver, s_ChanServ)) { if (!is_oper(u) && CSOpersOnly) notice_lang(s_ChanServ, u, ACCESS_DENIED); else - chanserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + chanserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (!stricmp(receiver, s_MemoServ)) { - memoserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + memoserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_HostServ && !stricmp(receiver, s_HostServ)) { - hostserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + hostserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_HelpServ && !stricmp(receiver, s_HelpServ)) { - helpserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + helpserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_BotServ && !stricmp(receiver, s_BotServ)) { - botserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + botserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_BotServ && (bi = findbot(receiver))) { - botmsgs(u, bi, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + botmsgs(u, bi, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX } /* Add to ignore list if the command took a significant amount of time. */ @@ -237,10 +237,10 @@ int m_stats(const char *source, int ac, const char **av) } else { for (i = 0; i < RootNumber; i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Root 0", ServicesRoots[i]); - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); + for (i = 0; i < servadmins.count && (nc = static_cast<NickCore *>(servadmins.list[i])); i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Admin 0", nc->display); - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); + for (i = 0; i < servopers.count && (nc = static_cast<NickCore *>(servopers.list[i])); i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Oper 0", nc->display); diff --git a/src/misc.c b/src/misc.c index 437d9ece4..ccdfeaf15 100644 --- a/src/misc.c +++ b/src/misc.c @@ -37,9 +37,9 @@ struct arc4_stream { int toupper(char c) { if (islower(c)) { - return (unsigned char) c - ('a' - 'A'); + return static_cast<int>(c) - ('a' - 'A'); } else { - return (unsigned char) c; + return static_cast<int>(c); } } @@ -54,9 +54,9 @@ int toupper(char c) int tolower(char c) { if (isupper(c)) { - return (unsigned char) c + ('a' - 'A'); + return static_cast<int>(c) + ('a' - 'A'); } else { - return (unsigned char) c; + return static_cast<int>(c); } } @@ -326,13 +326,13 @@ int process_numlist(const char *numstr, int *count_ret, * end of a valid number or range to the next comma or null. */ for (;;) { - n1 = n2 = strtol(numstr, (char **) &numstr, 10); + n1 = n2 = strtol(numstr, const_cast<char **>(&numstr), 10); numstr += strcspn(numstr, "0123456789,-"); if (*numstr == '-') { numstr++; numstr += strcspn(numstr, "0123456789,"); if (isdigit(*numstr)) { - n2 = strtol(numstr, (char **) &numstr, 10); + n2 = strtol(numstr, const_cast<char **>(&numstr), 10); numstr += strcspn(numstr, "0123456789,-"); } } @@ -387,7 +387,7 @@ int dotime(const char *s) return -1; } - amount = strtol(s, (char **) &s, 10); + amount = strtol(s, const_cast<char **>(&s), 10); if (*s) { switch (*s) { case 's': @@ -937,7 +937,7 @@ static void arc4_addrandom(void *dat, int datlen) for (n = 0; n < 256; n++) { rs.i = (rs.i + 1); si = rs.s[rs.i]; - rs.j = (rs.j + si + ((unsigned char *) dat)[n % datlen]); + rs.j = (rs.j + si + (static_cast<unsigned char *>(dat))[n % datlen]); rs.s[rs.i] = rs.s[rs.j]; rs.s[rs.j] = si; } @@ -1130,9 +1130,9 @@ char *str_signed(unsigned char *str) { char *nstr; - nstr = (char *) str; + nstr = reinterpret_cast<char *>(str); while (*str) { - *nstr = (char) *str; + *nstr = static_cast<char>(*str); str++; nstr++; } @@ -1157,7 +1157,7 @@ char *stripModePrefix(const char *str) void ntoa(struct in_addr addr, char *ipaddr, int len) { - unsigned char *bytes = (unsigned char *) &addr.s_addr; + unsigned char *bytes = reinterpret_cast<unsigned char *>(&addr.s_addr); snprintf(ipaddr, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]); } @@ -1176,7 +1176,7 @@ char **buildStringList(const std::string &src, int *number) while (tokens.GetToken(token)) { i++; - list = (char **)realloc(list, sizeof(char *) * i); + list = static_cast<char **>(realloc(list, sizeof(char *) * i)); list[i - 1] = sstrdup(token.c_str()); } *number = i; /* always zero it, even if we have no setters */ diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 4f478c946..f584fe3ff 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -51,7 +51,7 @@ static int moduleCopyFile(const char *name, const char *output) strncat(input, MODULE_EXT, 4095 - len); #ifndef _WIN32 - if ((srcfp = mkstemp((char *)output)) == -1) + if ((srcfp = mkstemp(const_cast<char *>(output))) == -1) return MOD_ERR_FILE_IO; #else if (!mktemp(output)) @@ -160,7 +160,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) } ano_modclearerr(); - func = (Module *(*)(const std::string &))ano_modsym(handle, "init_module"); + func = reinterpret_cast<Module *(*)(const std::string &)>(ano_modsym(handle, "init_module")); if (func == NULL && (err = ano_moderr()) != NULL) { alog("No magical init function found, not an Anope module"); @@ -263,7 +263,7 @@ void ModuleManager::DeleteModule(Module *m) handle = m->handle; ano_modclearerr(); - destroy_func = (void(*)(Module *m))ano_modsym(m->handle, "destroy_module"); + destroy_func = reinterpret_cast<void (*)(Module *)>(ano_modsym(m->handle, "destroy_module")); if (destroy_func == NULL && (err = ano_moderr()) != NULL) { alog("No magical destroy function found, chancing delete..."); diff --git a/src/modules.c b/src/modules.c index 9217915f6..c701355ab 100644 --- a/src/modules.c +++ b/src/modules.c @@ -53,7 +53,7 @@ char *ModuleGetErrStr(int status) "Module Error, No Service found for request", /* MOD_ERR_NOSERVICE */ "Module Error, No module name for request" /* MOD_ERR_NO_MOD_NAME */ }; - return (char *) module_err_str[status]; + return const_cast<char *>(module_err_str[status]); } @@ -310,7 +310,7 @@ static int internal_addCommand(Module *m, CommandHash * cmdTable[], Command * c, current->c = c; if (debug) alog("debug: existing cmd: (0x%p), new cmd (0x%p)", - (void *) c->next, (void *) c); + static_cast<void *>(c->next), static_cast<void *>(c)); return MOD_ERR_OK; } else if (pos == 2) { @@ -319,7 +319,7 @@ static int internal_addCommand(Module *m, CommandHash * cmdTable[], Command * c, tail = tail->next; if (debug) alog("debug: existing cmd: (0x%p), new cmd (0x%p)", - (void *) tail, (void *) c); + static_cast<void *>(tail), static_cast<void *>(c)); tail->next = c; c->next = NULL; @@ -616,7 +616,7 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos) current->m = m; if (debug) alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) m->next, (void *) m); + static_cast<void *>(m->next), static_cast<void *>(m)); return MOD_ERR_OK; } else if (pos == 2) { tail = current->m; @@ -624,7 +624,7 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos) tail = tail->next; if (debug) alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) tail, (void *) m); + static_cast<void *>(tail), static_cast<void *>(m)); tail->next = m; m->next = NULL; return MOD_ERR_OK; @@ -792,7 +792,7 @@ int Module::AddCallback(const char *name, time_t when, } if (debug) alog("debug: added module CallBack: [%s] due to execute at %ld", - newcb->name ? newcb->name : "?", (long int) newcb->when); + newcb->name ? newcb->name : "?", static_cast<long>(newcb->when)); return MOD_ERR_OK; } diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index 0c6e8966b..0a88b62b7 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -557,11 +557,11 @@ void req_send_memos(User * u, char *vHost) if (HSRequestMemoOper == 1) { for (i = 0; i < servopers.count; i++) { - my_memo_lang(u, (((NickCore *) servopers.list[i])->display), z, + my_memo_lang(u, ((static_cast<NickCore *>(servopers.list[i]))->display), z, LNG_REQUEST_MEMO, vHost); } for (i = 0; i < servadmins.count; i++) { - my_memo_lang(u, (((NickCore *) servadmins.list[i])->display), + my_memo_lang(u, ((static_cast<NickCore *>(servadmins.list[i]))->display), z, LNG_REQUEST_MEMO, vHost); } for (i = 0; i < RootNumber; i++) { @@ -860,7 +860,7 @@ void hsreq_load_db(void) vhost = myStrGetToken(buf, ':', 2); tmp = myStrGetToken(buf, ':', 3); if (tmp) { - tmp_time = strtol(tmp, (char **) NULL, 16); + tmp_time = strtol(tmp, NULL, 16); delete [] tmp; } else { tmp_time = 0; @@ -913,7 +913,7 @@ void hsreq_save_db(void) while (current) { vident = (current->vIdent ? current->vIdent : "(null)"); fprintf(fp, "%s:%s:%s:%X:%s\n", current->nick, vident, - current->vHost, (uint32) current->time, current->creator); + current->vHost, static_cast<uint32>(current->time), current->creator); current = current->next; } diff --git a/src/modules/os_ignore_db.c b/src/modules/os_ignore_db.c index 860658a9f..4fa4f10c1 100644 --- a/src/modules/os_ignore_db.c +++ b/src/modules/os_ignore_db.c @@ -217,7 +217,7 @@ void load_ignore_db(void) { if (!ign) { /* Create a fresh entry.. */ ign = new IgnoreData; - ign->mask = (char *)sstrdup(mask); + ign->mask = sstrdup(mask); ign->time = expiry_time; ign->prev = NULL; ign->next = ignore; @@ -254,7 +254,7 @@ void load_ignore_db(void) { expiry_time = atoi(value); } else if (!stricmp(key, "IGNORE_DB_VERSION")) { - if ((int)atoi(value) != IGNOREDBVERSION) { + if (atoi(value) != IGNOREDBVERSION) { alog("[\002os_ignore_db\002] Database version does not match any database versions supported by this module."); alog("[\002os_ignore_db\002] Continuing with clean database..."); break; diff --git a/src/news.c b/src/news.c index d113fc317..6dd3df335 100644 --- a/src/news.c +++ b/src/news.c @@ -172,7 +172,7 @@ void load_news() news_size = 32767; else news_size = 2 * nnews; - news = (NewsItem *)scalloc(sizeof(*news) * news_size, 1); + news = static_cast<NewsItem *>(scalloc(sizeof(*news) * news_size, 1)); if (!nnews) { close_db(f); return; @@ -440,7 +440,7 @@ static int add_newsitem(User * u, const char *text, short type) news_size = 8; else news_size *= 2; - news = (NewsItem *)srealloc(news, sizeof(*news) * news_size); + news = static_cast<NewsItem *>(srealloc(news, sizeof(*news) * news_size)); } num = 0; for (i = nnews - 1; i >= 0; i--) { diff --git a/src/nickserv.c b/src/nickserv.c index ed69455b2..4cb3a54fb 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -263,19 +263,19 @@ void load_ns_dbase(void) SAFE(read_int16(&nc->accesscount, f)); if (nc->accesscount) { char **access; - access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1); + access = static_cast<char **>(scalloc(sizeof(char *) * nc->accesscount, 1)); nc->access = access; for (j = 0; j < nc->accesscount; j++, access++) SAFE(read_string(access, f)); } SAFE(read_int16(&tmp16, f)); - nc->memos.memocount = (int16) tmp16; + nc->memos.memocount = static_cast<int16>(tmp16); SAFE(read_int16(&tmp16, f)); - nc->memos.memomax = (int16) tmp16; + nc->memos.memomax = static_cast<int16>(tmp16); if (nc->memos.memocount) { Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1); + memos = static_cast<Memo *>(scalloc(sizeof(Memo) * nc->memos.memocount, 1)); nc->memos.memos = memos; for (j = 0; j < nc->memos.memocount; j++, memos++) { SAFE(read_int32(&memos->number, f)); @@ -914,7 +914,7 @@ void change_core_display(NickCore * nc, char *newdisplay) if (nc->aliases.count <= 0) return; - na = (NickAlias *)nc->aliases.list[0]; + na = static_cast<NickAlias *>(nc->aliases.list[0]); newdisplay = na->nick; } @@ -1172,7 +1172,7 @@ static void rem_ns_timeout(NickAlias * na, int type) static void timeout_collide(Timeout * t) { - NickAlias *na = (NickAlias *)t->data; + NickAlias *na = static_cast<NickAlias *>(t->data); rem_ns_timeout(na, TO_COLLIDE); /* If they identified or don't exist anymore, don't kill them. */ @@ -1191,7 +1191,7 @@ static void timeout_collide(Timeout * t) static void timeout_release(Timeout * t) { - NickAlias *na = (NickAlias *)t->data; + NickAlias *na = static_cast<NickAlias *>(t->data); rem_ns_timeout(na, TO_RELEASE); release(na, 1); @@ -1213,7 +1213,7 @@ static void add_ns_timeout(NickAlias * na, int type, time_t delay) timeout_routine = timeout_release; else { alog("NickServ: unknown timeout type %d! na=0x%p (%s), delay=%ld", - type, (void *) na, na->nick, (long int) delay); + type, static_cast<void *>(na), na->nick, static_cast<long>(delay)); return; } diff --git a/src/operserv.c b/src/operserv.c index fe270fd38..1ba9470e9 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -284,7 +284,7 @@ void save_os_dbase(void) SAFE(write_int16(akills.count, f)); for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; + ak = static_cast<Akill *>(akills.list[i]); SAFE(write_string(ak->user, f)); SAFE(write_string(ak->host, f)); @@ -296,7 +296,7 @@ void save_os_dbase(void) SAFE(write_int16(sglines.count, f)); for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; + sx = static_cast<SXLine *>(sglines.list[i]); SAFE(write_string(sx->mask, f)); SAFE(write_string(sx->by, f)); @@ -307,7 +307,7 @@ void save_os_dbase(void) SAFE(write_int16(sqlines.count, f)); for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; + sx = static_cast<SXLine *>(sqlines.list[i]); SAFE(write_string(sx->mask, f)); SAFE(write_string(sx->by, f)); @@ -318,7 +318,7 @@ void save_os_dbase(void) SAFE(write_int16(szlines.count, f)); for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; + sx = static_cast<SXLine *>(szlines.list[i]); SAFE(write_string(sx->mask, f)); SAFE(write_string(sx->by, f)); @@ -516,7 +516,7 @@ int add_akill(User * u, char *mask, const char *by, const time_t expires, for (i = akills.count - 1; i >= 0; i--) { char amask[BUFSIZE]; - entry = (Akill *)akills.list[i]; + entry = static_cast<Akill *>(akills.list[i]); if (!entry) continue; @@ -626,7 +626,7 @@ int check_akill(const char *nick, const char *username, const char *host, return 0; for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; + ak = static_cast<Akill *>(akills.list[i]); if (!ak) continue; if (match_wild_nocase(ak->user, username) @@ -670,7 +670,7 @@ void expire_akills(void) Akill *ak; for (i = akills.count - 1; i >= 0; i--) { - ak = (Akill *)akills.list[i]; + ak = static_cast<Akill *>(akills.list[i]); if (!ak->expires || ak->expires > now) continue; @@ -684,7 +684,7 @@ void expire_akills(void) static void free_akill_entry(SList * slist, void *item) { - Akill *ak = (Akill *)item; + Akill *ak = static_cast<Akill *>(item); /* Remove the AKILLs from all the servers */ ircdproto->SendAkillDel(ak->user, ak->host); @@ -702,8 +702,8 @@ static void free_akill_entry(SList * slist, void *item) static int is_akill_entry_equal(SList * slist, void *item1, void *item2) { - char *ak1 = (char *)item1, buf[BUFSIZE]; - Akill *ak2 = (Akill *)item2; + char *ak1 = static_cast<char *>(item1), buf[BUFSIZE]; + Akill *ak2 = static_cast<Akill *>(item2); if (!ak1 || !ak2) return 0; @@ -747,7 +747,7 @@ int add_sgline(User * u, char *mask, const char *by, const time_t expires, if (sglines.count > 0) { for (i = sglines.count - 1; i >= 0; i--) { - entry = (SXLine *)sglines.list[i]; + entry = static_cast<SXLine *>(sglines.list[i]); if (!entry) continue; @@ -834,7 +834,7 @@ int check_sgline(const char *nick, const char *realname) return 0; for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; + sx = static_cast<SXLine *>(sglines.list[i]); if (!sx) continue; @@ -858,7 +858,7 @@ void expire_sglines(void) SXLine *sx; for (i = sglines.count - 1; i >= 0; i--) { - sx = (SXLine *)sglines.list[i]; + sx = static_cast<SXLine *>(sglines.list[i]); if (!sx->expires || sx->expires > now) continue; @@ -872,7 +872,7 @@ void expire_sglines(void) static void free_sgline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = static_cast<SXLine *>(item); /* Remove the SGLINE from all the servers */ ircdproto->SendSGLineDel(sx->mask); @@ -888,8 +888,8 @@ static void free_sgline_entry(SList * slist, void *item) static int is_sgline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = static_cast<char *>(item1); + SXLine *sx2 = static_cast<SXLine *>(item2); if (!sx1 || !sx2) return 0; @@ -930,7 +930,7 @@ int add_sqline(User * u, char *mask, const char *by, const time_t expires, if (sqlines.count > 0) { for (i = sqlines.count - 1; i >= 0; i--) { - entry = (SXLine *)sqlines.list[i]; + entry = static_cast<SXLine *>(sqlines.list[i]); if (!entry) continue; @@ -1023,7 +1023,7 @@ int check_sqline(const char *nick, int nick_change) return 0; for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; + sx = static_cast<SXLine *>(sqlines.list[i]); if (!sx) continue; @@ -1053,7 +1053,7 @@ int check_chan_sqline(const char *chan) return 0; for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; + sx = static_cast<SXLine *>(sqlines.list[i]); if (!sx) continue; @@ -1078,7 +1078,7 @@ void expire_sqlines(void) SXLine *sx; for (i = sqlines.count - 1; i >= 0; i--) { - sx = (SXLine *)sqlines.list[i]; + sx = static_cast<SXLine *>(sqlines.list[i]); if (!sx->expires || sx->expires > now) continue; @@ -1093,7 +1093,7 @@ void expire_sqlines(void) static void free_sqline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = static_cast<SXLine *>(item); /* Remove the SQLINE from all the servers */ ircdproto->SendSQLineDel(sx->mask); @@ -1109,8 +1109,8 @@ static void free_sqline_entry(SList * slist, void *item) static int is_sqline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = static_cast<char *>(item1); + SXLine *sx2 = static_cast<SXLine *>(item2); if (!sx1 || !sx2) return 0; @@ -1148,7 +1148,7 @@ int add_szline(User * u, char *mask, const char *by, const time_t expires, if (szlines.count > 0) { for (i = szlines.count - 1; i >= 0; i--) { - entry = (SXLine *)szlines.list[i]; + entry = static_cast<SXLine *>(szlines.list[i]); if (!entry) continue; @@ -1223,7 +1223,7 @@ int check_szline(const char *nick, char *ip) } for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; + sx = static_cast<SXLine *>(szlines.list[i]); if (!sx) { continue; } @@ -1247,7 +1247,7 @@ void expire_szlines(void) SXLine *sx; for (i = szlines.count - 1; i >= 0; i--) { - sx = (SXLine *)szlines.list[i]; + sx = static_cast<SXLine *>(szlines.list[i]); if (!sx->expires || sx->expires > now) continue; @@ -1261,7 +1261,7 @@ void expire_szlines(void) static void free_szline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = static_cast<SXLine *>(item); /* Remove the SZLINE from all the servers */ ircdproto->SendSZLineDel(sx->mask); @@ -1278,8 +1278,8 @@ static void free_szline_entry(SList * slist, void *item) static int is_szline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = static_cast<char *>(item1); + SXLine *sx2 = static_cast<SXLine *>(item2); if (!sx1 || !sx2) return 0; @@ -1297,7 +1297,7 @@ static int is_szline_entry_equal(SList * slist, void *item1, void *item2) static int compare_adminlist_entries(SList * slist, void *item1, void *item2) { - NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; + NickCore *nc1 = static_cast<NickCore *>(item1), *nc2 = static_cast<NickCore *>(item2); if (!nc1 || !nc2) return -1; /* To tell to continue */ return stricmp(nc1->display, nc2->display); @@ -1307,7 +1307,7 @@ static int compare_adminlist_entries(SList * slist, void *item1, static void free_adminlist_entry(SList * slist, void *item) { - NickCore *nc = (NickCore *)item; + NickCore *nc = static_cast<NickCore *>(item); nc->flags &= ~NI_SERVICES_ADMIN; } @@ -1318,7 +1318,7 @@ static void free_adminlist_entry(SList * slist, void *item) static int compare_operlist_entries(SList * slist, void *item1, void *item2) { - NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; + NickCore *nc1 = static_cast<NickCore *>(item1), *nc2 = static_cast<NickCore *>(item2); if (!nc1 || !nc2) return -1; /* To tell to continue */ return stricmp(nc1->display, nc2->display); @@ -1328,7 +1328,7 @@ static int compare_operlist_entries(SList * slist, void *item1, static void free_operlist_entry(SList * slist, void *item) { - NickCore *nc = (NickCore *)item; + NickCore *nc = static_cast<NickCore *>(item); nc->flags &= ~NI_SERVICES_OPER; } @@ -1465,7 +1465,7 @@ int defconParseModeString(const char *str) continue; } - if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { + if (static_cast<int>(mode) < 128 && (cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) { if (cbm->flags & CBM_NO_MLOCK) { alog("DefConChanModes mode character '%c' cannot be locked", mode); delete [] str_copy; diff --git a/src/process.c b/src/process.c index 43ea0cf77..cb5bf7bd0 100644 --- a/src/process.c +++ b/src/process.c @@ -253,12 +253,12 @@ int split_buf(char *buf, const char ***argv, int colon_special) int argc; char *s; - *argv = (const char **)scalloc(sizeof(const char *) * argvsize, 1); + *argv = static_cast<const char **>(scalloc(sizeof(const char *) * argvsize, 1)); argc = 0; while (*buf) { if (argc == argvsize) { argvsize += 8; - *argv = (const char **)srealloc(*argv, sizeof(const char *) * argvsize); + *argv = static_cast<const char **>(srealloc(*argv, sizeof(const char *) * argvsize)); } if (*buf == ':') { (*argv)[argc++] = buf + 1; @@ -310,7 +310,7 @@ void process() * crash - in that case, we want to know what we crashed on. */ strscpy(buf, inbuf, sizeof(buf)); - doCleanBuffer((char *) buf); + doCleanBuffer(buf); /* Split the buffer into pieces. */ if (*buf == ':') { diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index 9854adeaf..9f92dffa4 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -441,7 +441,7 @@ void bahamut_cmd_burst() */ void bahamut_cmd_svinfo() { - send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 3 1 0 :%ld", static_cast<long>(time(NULL))); } /* PASS */ @@ -524,7 +524,7 @@ class BahamutIRCdProto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const char *nick) { - send_cmd(ServerName, "SVSHOLD %s %u :%s", nick, (unsigned int)NSReleaseTimeout, "Being held for registered user"); + send_cmd(ServerName, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(NSReleaseTimeout), "Being held for registered user"); } /* SVSHOLD - release */ @@ -631,7 +631,7 @@ class BahamutIRCdProto : public IRCDProto // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = expires - time(NULL); if (timeleft > 172800) timeleft = 172800; - send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, (unsigned int)timeleft, who, static_cast<long>(time(NULL)), reason); + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, static_cast<int>(timeleft), who, static_cast<long>(time(NULL)), reason); } /* SVSKILL */ diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index ebc694745..6ea1c2b2c 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -428,7 +428,7 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost) int anope_event_idle(const char *source, int ac, const char **av) { if (ac == 1) { - send_cmd(av[0], "IDLE %s %ld 0", source, (long int) time(NULL)); + send_cmd(av[0], "IDLE %s %ld 0", source, static_cast<long>(time(NULL))); } return MOD_CONT; } @@ -1071,7 +1071,7 @@ int anope_event_nick(const char *source, int ac, const char **av) { User *user; struct in_addr addy; - uint32 *ad = (uint32 *) & addy; + uint32 *ad = reinterpret_cast<uint32 *>(&addy); if (ac != 1) { if (ac == 8) { diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 205e91897..dc46f95e2 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -427,7 +427,7 @@ int anope_event_idle(const char *source, int ac, const char **av) if (!bi) return MOD_CONT; - send_cmd(bi->uid, "IDLE %s %ld 0", source, (long int) time(NULL)); + send_cmd(bi->uid, "IDLE %s %ld 0", source, static_cast<long>(time(NULL))); return MOD_CONT; } @@ -629,7 +629,7 @@ class InspIRCdProto : public IRCDProto void SendSVSHold(const char *nick) { BotInfo *bi = findbot(s_OperServ); - send_cmd(bi->uid, "SVSHOLD %s %ud :%s", nick, (unsigned int)NSReleaseTimeout, "Being held for registered user"); + send_cmd(bi->uid, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(NSReleaseTimeout), "Being held for registered user"); } /* SVSHOLD - release */ @@ -701,7 +701,7 @@ class InspIRCdProto : public IRCDProto send_cmd(ircd->ts6 ? bi->uid : bi->nick, "SNONOTICE A :%s", buf); } } - + int IsNickValid(const char *nick) { /* InspIRCd, like TS6, uses UIDs on collision, so... */ @@ -1104,7 +1104,7 @@ int anope_event_uid(const char *source, int ac, const char **av) User *user; struct in_addr addy; Server *s = findserver_uid(servlist, source); - uint32 *ad = (uint32 *) &addy; + uint32 *ad = reinterpret_cast<uint32 *>(&addy); int svid = 0; int ts = strtoul(av[1], NULL, 10); diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index a91d676a6..efe61bd27 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -420,7 +420,7 @@ CUMode myCumodes[128] = { */ void ratbox_cmd_svinfo() { - send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 6 3 0 :%ld", static_cast<long>(time(NULL))); } void ratbox_cmd_svsinfo() @@ -1029,12 +1029,12 @@ int anope_event_capab(const char *source, int ac, const char **av) return MOD_CONT; /* We get the params as one arg, we should split it for capab_parse */ - argv = (const char **)scalloc(argvsize, sizeof(const char *)); + argv = static_cast<const char **>(scalloc(argvsize, sizeof(const char *))); argc = 0; while ((str = myStrGetToken(av[0], ' ', argc))) { if (argc == argvsize) { argvsize += 8; - argv = (const char **)srealloc(argv, argvsize * sizeof(const char *)); + argv = static_cast<const char **>(srealloc(argv, argvsize * sizeof(const char *))); } argv[argc] = str; argc++; @@ -1046,7 +1046,7 @@ int anope_event_capab(const char *source, int ac, const char **av) for (argvsize = 0; argvsize < argc; argvsize++) { delete [] argv[argvsize]; } - free((char **)argv); + free(const_cast<char **>(argv)); return MOD_CONT; } diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 74bafd0f9..b6986861e 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -475,7 +475,7 @@ void unreal_cmd_svswatch(const char *sender, const char *nick, const char *parm) void unreal_cmd_netinfo(int ac, const char **av) { - send_cmd(NULL, "AO %ld %ld %d %s 0 0 0 :%s", (long int) maxusercnt, (long int) time(NULL), atoi(av[2]), av[3], av[7]); + send_cmd(NULL, "AO %ld %ld %d %s 0 0 0 :%s", static_cast<long>(maxusercnt), static_cast<long>(time(NULL)), atoi(av[2]), av[3], av[7]); } /* PROTOCTL */ /* @@ -1335,7 +1335,7 @@ int anope_event_sdesc(const char *source, int ac, const char **av) s = findserver(servlist, source); if (s) { - s->desc = (char *)av[0]; // XXX Unsafe cast -- CyberBotX + s->desc = const_cast<char *>(av[0]); // XXX Unsafe cast -- CyberBotX } return MOD_CONT; diff --git a/src/servers.c b/src/servers.c index 4e57bc430..97fe5da07 100644 --- a/src/servers.c +++ b/src/servers.c @@ -291,7 +291,7 @@ Server *findserver(Server * s, const char *name) } if (debug) - alog("debug: findserver(%s) -> %p", name, (void *) s); + alog("debug: findserver(%s) -> %p", name, static_cast<void *>(s)); return s; } @@ -337,7 +337,7 @@ Server *findserver_uid(Server * s, const char *name) } if (debug) - alog("debug: findserver_uid(%s) -> %p", name, (void *) s); + alog("debug: findserver_uid(%s) -> %p", name, static_cast<void *>(s)); return s; } diff --git a/src/sessions.c b/src/sessions.c index 83c7d8474..3c882032d 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -345,7 +345,7 @@ void expire_exceptions(void) nexceptions--; memmove(exceptions + i, exceptions + i + 1, sizeof(Exception) * (nexceptions - i)); - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + exceptions = static_cast<Exception *>(srealloc(exceptions, sizeof(Exception) * nexceptions)); i--; } } @@ -411,7 +411,7 @@ void load_exceptions() case 7: SAFE(read_int16(&n, f)); nexceptions = n; - exceptions = (Exception *)scalloc(sizeof(Exception) * nexceptions, 1); + exceptions = static_cast<Exception *>(scalloc(sizeof(Exception) * nexceptions, 1)); if (!nexceptions) { close_db(f); return; @@ -505,7 +505,7 @@ int exception_add(User * u, const char *mask, const int limit, } nexceptions++; - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + exceptions = static_cast<Exception *>(srealloc(exceptions, sizeof(Exception) * nexceptions)); exceptions[nexceptions - 1].mask = sstrdup(mask); exceptions[nexceptions - 1].limit = limit; @@ -530,7 +530,7 @@ static int exception_del(const int index) nexceptions--; memmove(exceptions + index, exceptions + index + 1, sizeof(Exception) * (nexceptions - index)); - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + exceptions = static_cast<Exception *>(srealloc(exceptions, sizeof(Exception) * nexceptions)); return 1; } @@ -775,7 +775,7 @@ int do_exception(User * u) if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions) && (n1 != n2)) { - exception = (Exception *)smalloc(sizeof(Exception)); + exception = static_cast<Exception *>(smalloc(sizeof(Exception))); memcpy(exception, &exceptions[n1], sizeof(Exception)); if (n1 < n2) { diff --git a/src/slist.c b/src/slist.c index cf84f69a0..008f29143 100644 --- a/src/slist.c +++ b/src/slist.c @@ -6,9 +6,9 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * $Id$ + * Based on the original code of Services by Andy Church. + * + * $Id$ * */ @@ -63,7 +63,7 @@ int slist_add(SList * slist, void *item) /** * Clears the list. If free is 1, the freeitem function will be called - * for each item before clearing. + * for each item before clearing. * @param slist Slist Struct * @param mustfree What is being freed * @return void @@ -89,7 +89,7 @@ void slist_clear(SList * slist, int mustfree) /*************************************************************************/ /** - * Deletes an item from the list, by index. Returns 1 if successful, + * Deletes an item from the list, by index. Returns 1 if successful, * 0 otherwise. * @param slist Slist Struct * @param index beign deleted @@ -136,14 +136,14 @@ int slist_delete_range(SList * slist, char *range, slist_delcheckcb_t cb, va_start(args, cb); for (;;) { - n1 = n2 = strtol(range, (char **) &range, 10); + n1 = n2 = strtol(range, &range, 10); range += strcspn(range, "0123456789,-"); if (*range == '-') { range++; range += strcspn(range, "0123456789,"); if (isdigit(*range)) { - n2 = strtol(range, (char **) &range, 10); + n2 = strtol(range, &range, 10); range += strcspn(range, "0123456789,-"); } } @@ -234,13 +234,13 @@ int slist_enum(SList * slist, char *range, slist_enumcb_t cb, ...) for (;;) { res = 0; - n1 = n2 = strtol(range, (char **) &range, 10); + n1 = n2 = strtol(range, &range, 10); range += strcspn(range, "0123456789,-"); if (*range == '-') { range++; range += strcspn(range, "0123456789,"); if (isdigit(*range)) { - n2 = strtol(range, (char **) &range, 10); + n2 = strtol(range, &range, 10); range += strcspn(range, "0123456789,-"); } } @@ -338,7 +338,7 @@ int slist_indexof(SList * slist, void *item) /*************************************************************************/ /** - * Removes all NULL pointers from the list. + * Removes all NULL pointers from the list. * @param slist Slist Struct * @return void */ @@ -384,7 +384,7 @@ int slist_setcapacity(SList * slist, int16 capacity) slist->capacity = capacity; if (slist->capacity) slist->list = - (void **)srealloc(slist->list, sizeof(void *) * slist->capacity); + static_cast<void **>(srealloc(slist->list, sizeof(void *) * slist->capacity)); else { free(slist->list); slist->list = NULL; diff --git a/src/sockutil.c b/src/sockutil.c index 2bfb4e204..772b4aacc 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -180,7 +180,7 @@ static int buffered_read_one(ano_socket_t fd) total_read++; if (debug >= 4) alog("debug: buffered_read_one(%d) returning %d", fd, c); - return (int) c & 0xFF; + return static_cast<int>(c) & 0xFF; } /*************************************************************************/ @@ -429,7 +429,7 @@ char *sgets(char *buf, int len, ano_socket_t s) flush_write_buffer(0); } if (read_buffer_len() == 0 && c == 0) - return (char *) -1; + return reinterpret_cast<char *>(-1); c = sgetc(s); while (--len && (*ptr++ = c) != '\n' && (c = sgetc(s)) >= 0); if (c < 0) @@ -452,7 +452,7 @@ char *sgets2(char *buf, int len, ano_socket_t s) { char *str = sgets(buf, len, s); - if (!str || str == (char *) -1) + if (!str || str == reinterpret_cast<char *>(-1)) return str; str = buf + strlen(buf) - 1; if (*str == '\n') @@ -565,11 +565,11 @@ int conn(const char *host, int port, const char *lhost, int lport) if (lhost) { #if HAVE_GETHOSTBYNAME if ((hp = gethostbyname(lhost)) != NULL) { - memcpy((char *) &lsa.sin_addr, hp->h_addr, hp->h_length); + memcpy(&lsa.sin_addr, hp->h_addr, hp->h_length); lsa.sin_family = hp->h_addrtype; #else if (addr = pack_ip(lhost)) { - memcpy((char *) &lsa.sin_addr, addr, 4); + memcpy(&lsa.sin_addr, addr, 4); lsa.sin_family = AF_INET; #endif } else { @@ -577,13 +577,13 @@ int conn(const char *host, int port, const char *lhost, int lport) } } if (lport) - lsa.sin_port = htons((unsigned short) lport); + lsa.sin_port = htons(static_cast<unsigned short>(lport)); memset(&sa, 0, sizeof(sa)); #if HAVE_GETHOSTBYNAME if (!(hp = gethostbyname(host))) return -1; - memcpy((char *) &sa.sin_addr, hp->h_addr, hp->h_length); + memcpy(&sa.sin_addr, hp->h_addr, hp->h_length); sa.sin_family = hp->h_addrtype; #else if (!(addr = pack_ip(host))) { @@ -591,28 +591,28 @@ int conn(const char *host, int port, const char *lhost, int lport) ano_sockseterr(SOCKERR_EINVAL); return -1; } - memcpy((char *) &sa.sin_addr, addr, 4); + memcpy(&sa.sin_addr, addr, 4); sa.sin_family = AF_INET; #endif - sa.sin_port = htons((unsigned short) port); + sa.sin_port = htons(static_cast<unsigned short>(port)); if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) return -1; if (setsockopt - (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &sockopt, + (sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&sockopt), sizeof(int)) < 0) alog("debug: couldn't set SO_REUSEADDR on socket"); if ((lhost || lport) - && bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { + && bind(sock, reinterpret_cast<struct sockaddr *>(&lsa), sizeof(lsa)) < 0) { int errno_save = ano_sockgeterr(); ano_sockclose(sock); ano_sockseterr(errno_save); return -1; } - if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { + if (connect(sock, reinterpret_cast<struct sockaddr *>(&sa), sizeof(sa)) < 0) { int errno_save = ano_sockgeterr(); ano_sockclose(sock); ano_sockseterr(errno_save); diff --git a/src/timeout.c b/src/timeout.c index e8cbf057a..f0c2df417 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -27,7 +27,7 @@ void check_timeouts(void) time_t t = time(NULL); if (debug >= 2) - alog("debug: Checking timeouts at %ld", (long int) t); + alog("debug: Checking timeouts at %ld", static_cast<long>(t)); to = timeouts; while (to) { @@ -37,7 +37,7 @@ void check_timeouts(void) } if (debug >= 4) { alog("debug: Running timeout 0x%p (code=0x%p repeat=%d)", - (void *) to, (void *) to->code, to->repeat); + static_cast<void *>(to), reinterpret_cast<void *>(to->code), to->repeat); } to->code(to); if (to->repeat) { diff --git a/src/users.c b/src/users.c index 93b7eef34..b437ae80d 100644 --- a/src/users.c +++ b/src/users.c @@ -384,7 +384,7 @@ User *finduser(const char *nick) while (user && stricmp(user->nick, nick) != 0) user = user->next; if (debug >= 3) - alog("debug: finduser(%s) -> 0x%p", nick, (void *) user); + alog("debug: finduser(%s) -> 0x%p", nick, static_cast<void *>(user)); return user; } @@ -748,7 +748,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const common_get_vident(user), common_get_vhost(user)); snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); + static_cast<unsigned long>(user->timestamp)); ircdproto->SendSVID2(user, tsbuf); alog("%s: %s!%s@%s automatically identified for nick %s", @@ -762,7 +762,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const if (nick_identified(user)) { char tsbuf[16]; snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); + static_cast<unsigned long>(user->timestamp)); ircdproto->SendSVID3(user, tsbuf); } } |