Spring cleaning redux:

- Implemented changes suggested by Jilles
- Remove some unused parameters in functions
- Remove some unused ssl procs
- 63-bit time_t support in TS deltas
- const char * vs char * cleanup
- struct alignment (void *) casts
- signed vs unsigned fixes
- bad memset() call
- Bad LT_MAIN in libratbox
- char -> unsigned char casts for isdigit/isspace/etc calls

Thanks Jilles!
This commit is contained in:
Jail Bird 2015-04-20 00:55:20 -05:00
parent 32fb589528
commit 29c92cf95f
40 changed files with 97 additions and 131 deletions

View File

@ -255,7 +255,7 @@ dummy_handler(int sig)
#endif #endif
static void static void
setup_signals() setup_signals(void)
{ {
#ifndef WINDOWS #ifndef WINDOWS
struct sigaction act; struct sigaction act;
@ -298,7 +298,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
setup_signals(); setup_signals();
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */ bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256); /* XXX fix me */
if(bandb_helper == NULL) if(bandb_helper == NULL)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -255,10 +255,10 @@ main(int argc, char *argv[])
if(flag.import) if(flag.import)
{ {
if(count.error && flag.verbose) if(count.error && flag.verbose)
fprintf(stderr, "* I was unable to locate %i config files to import.\n", fprintf(stderr, "* I was unable to locate %u config files to import.\n",
count.error); count.error);
fprintf(stdout, "* Import Stats: Klines: %i, Dlines: %i, Xlines: %i, Resvs: %i \n", fprintf(stdout, "* Import Stats: Klines: %u, Dlines: %u, Xlines: %u, Resvs: %u \n",
count.klines, count.dlines, count.xlines, count.resvs); count.klines, count.dlines, count.xlines, count.resvs);
fprintf(stdout, fprintf(stdout,

View File

@ -120,7 +120,7 @@ static int
rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames) rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames)
{ {
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc); rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
(cb) (argc, (const char **)argv); (cb) (argc, (const char **)(void *)argv);
return 0; return 0;
} }

View File

@ -141,7 +141,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
if (*tptr == '.') if (*tptr == '.')
break; break;
if (isdigit(*tptr) || *tptr == '-') if (isdigit((unsigned char)*tptr) || *tptr == '-')
continue; continue;
*tptr = b26_alphabet[(*tptr + accum) % 26]; *tptr = b26_alphabet[(*tptr + accum) % 26];
@ -153,7 +153,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
/* pass 2: scramble each number in the address */ /* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++)
{ {
if (isdigit(*tptr)) if (isdigit((unsigned char)*tptr))
*tptr = '0' + (*tptr + accum) % 10; *tptr = '0' + (*tptr + accum) % 10;
accum = (accum << 1) | (accum >> 31); accum = (accum << 1) | (accum >> 31);

View File

@ -151,7 +151,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
if (*tptr == '.') if (*tptr == '.')
break; break;
if (isdigit(*tptr) || *tptr == '-') if (isdigit((unsigned char)*tptr) || *tptr == '-')
continue; continue;
*tptr = b26_alphabet[(*tptr * accum) % 26]; *tptr = b26_alphabet[(*tptr * accum) % 26];
@ -160,7 +160,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
/* pass 2: scramble each number in the address */ /* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++)
{ {
if (isdigit(*tptr)) if (isdigit((unsigned char)*tptr))
{ {
*tptr = 48 + ((*tptr * accum) % 10); *tptr = 48 + ((*tptr * accum) % 10);
} }

View File

@ -141,7 +141,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
if (*tptr == '.') if (*tptr == '.')
break; break;
if (isdigit(*tptr) || *tptr == '-') if (isdigit((unsigned char)*tptr) || *tptr == '-')
continue; continue;
*tptr = b26_alphabet[(*tptr + accum) % 26]; *tptr = b26_alphabet[(*tptr + accum) % 26];
@ -153,7 +153,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
/* pass 2: scramble each number in the address */ /* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++) for (tptr = outbuf; *tptr != '\0'; tptr++)
{ {
if (isdigit(*tptr)) if (isdigit((unsigned char)*tptr))
*tptr = '0' + (*tptr + accum) % 10; *tptr = '0' + (*tptr + accum) % 10;
accum = (accum << 1) | (accum >> 31); accum = (accum << 1) | (accum >> 31);

View File

@ -71,7 +71,7 @@ distribute_hostchange(struct Client *client_p, char *newhost)
static void static void
do_host_cloak(const char *inbuf, char *outbuf, int ipmask) do_host_cloak(const char *inbuf, char *outbuf, int ipmask)
{ {
int cyc; unsigned int cyc;
unsigned int hosthash = 1, hosthash2 = 1; unsigned int hosthash = 1, hosthash2 = 1;
unsigned int maxcycle = strlen(inbuf); unsigned int maxcycle = strlen(inbuf);
int len1; int len1;

View File

@ -36,7 +36,7 @@ enum
#endif #endif
}; };
int parse_netmask(const char *, struct sockaddr *, int *); int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost, struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
const char *orighost, struct sockaddr *, const char *orighost, struct sockaddr *,
int, int, const char *, const char *); int, int, const char *, const char *);

View File

@ -350,7 +350,7 @@ extern int detach_conf(struct Client *);
extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *); extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *);
extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *); extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
extern void get_printable_conf(struct ConfItem *, extern void get_printable_conf(struct ConfItem *,
char **, char **, char **, char **, int *, char **); char **, char **, const char **, char **, int *, char **);
extern char *get_user_ban_reason(struct ConfItem *aconf); extern char *get_user_ban_reason(struct ConfItem *aconf);
extern void get_printable_kline(struct Client *, struct ConfItem *, extern void get_printable_kline(struct Client *, struct ConfItem *,
char **, char **, char **, char **); char **, char **, char **, char **);

View File

@ -38,7 +38,7 @@ extern int valid_hostname(const char *hostname);
extern int valid_username(const char *username); extern int valid_username(const char *username);
extern int user_mode(struct Client *, struct Client *, int, const char **); extern int user_mode(struct Client *, struct Client *, int, const char **);
extern void send_umode(struct Client *, struct Client *, int, int, char *); extern void send_umode(struct Client *, struct Client *, int, char *);
extern void send_umode_out(struct Client *, struct Client *, int); extern void send_umode_out(struct Client *, struct Client *, int);
extern int show_lusers(struct Client *source_p); extern int show_lusers(struct Client *source_p);
extern int register_local_user(struct Client *, struct Client *, const char *); extern int register_local_user(struct Client *, struct Client *, const char *);

View File

@ -124,7 +124,7 @@ char *rb_strerror(int error);
#else #else
#define slrb_assert(expr) do \ #define slrb_assert(expr) do \
if(rb_unlikely(!(expr))) { \ if(rb_unlikely(!(expr))) { \
rb_lib_log(L_MAIN, \ rb_lib_log( \
"file: %s line: %d: Assertion failed: (%s)", \ "file: %s line: %d: Assertion failed: (%s)", \
__FILE__, __LINE__, #expr); \ __FILE__, __LINE__, #expr); \
} \ } \

View File

@ -41,7 +41,7 @@ rb_helper *rb_helper_start(const char *name, const char *fullpath, rb_helper_cb
rb_helper *rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, rb_helper *rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb,
log_cb * ilog, restart_cb * irestart, die_cb * idie, log_cb * ilog, restart_cb * irestart, die_cb * idie,
int maxcon, size_t lb_heap_size, size_t dh_size, size_t fd_heap_size); size_t lb_heap_size, size_t dh_size, size_t fd_heap_size);
void rb_helper_restart(rb_helper *helper); void rb_helper_restart(rb_helper *helper);
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -1514,7 +1514,7 @@ inet_pton6(const char *src, unsigned char *dst)
curtok = src; curtok = src;
saw_xdigit = 0; saw_xdigit = 0;
val = 0; val = 0;
while((ch = tolower(*src++)) != '\0') while((ch = tolower((unsigned char)*src++)) != '\0')
{ {
const char *pch; const char *pch;

View File

@ -42,7 +42,7 @@ struct _rb_helper
/* setup all the stuff a new child needs */ /* setup all the stuff a new child needs */
rb_helper * rb_helper *
rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog, rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog,
restart_cb * irestart, die_cb * idie, int maxcon, size_t lb_heap_size, restart_cb * irestart, die_cb * idie, size_t lb_heap_size,
size_t dh_size, size_t fd_heap_size) size_t dh_size, size_t fd_heap_size)
{ {
rb_helper *helper; rb_helper *helper;

View File

@ -399,7 +399,7 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, fprintf(stderr,
"patricia_search_exact: take right at %d\n", node->bit); "patricia_search_exact: take right at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->r; node = node->r;
} }
@ -412,7 +412,7 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, fprintf(stderr,
"patricia_search_exact: take left at %d\n", node->bit); "patricia_search_exact: take left at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->l; node = node->l;
} }
@ -423,10 +423,10 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
#ifdef PATRICIA_DEBUG #ifdef PATRICIA_DEBUG
if(node->prefix) if(node->prefix)
fprintf(stderr, "patricia_search_exact: stop at %s/%d %d\n", fprintf(stderr, "patricia_search_exact: stop at %s/%d %u\n",
prefix_toa(node->prefix), node->prefix->bitlen, node->bit); prefix_toa(node->prefix), node->prefix->bitlen, node->bit);
else else
fprintf(stderr, "patricia_search_exact: stop at %d\n", node->bit); fprintf(stderr, "patricia_search_exact: stop at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
if(node->bit > bitlen || node->prefix == NULL) if(node->bit > bitlen || node->prefix == NULL)
return (NULL); return (NULL);
@ -486,7 +486,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, fprintf(stderr,
"patricia_search_best: take right at %d\n", node->bit); "patricia_search_best: take right at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->r; node = node->r;
} }
@ -499,7 +499,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, fprintf(stderr,
"patricia_search_best: take left at %d\n", node->bit); "patricia_search_best: take left at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->l; node = node->l;
} }
@ -518,7 +518,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
fprintf(stderr, "patricia_search_best: stop at %s/%d\n", fprintf(stderr, "patricia_search_best: stop at %s/%d\n",
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, "patricia_search_best: stop at %d\n", node->bit); fprintf(stderr, "patricia_search_best: stop at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
if(cnt <= 0) if(cnt <= 0)
@ -601,7 +601,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
"patricia_lookup: take right %s/%d\n", "patricia_lookup: take right %s/%d\n",
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, "patricia_lookup: take right at %d\n", node->bit); fprintf(stderr, "patricia_lookup: take right at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->r; node = node->r;
} }
@ -615,7 +615,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
"patricia_lookup: take left %s/%d\n", "patricia_lookup: take left %s/%d\n",
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, "patricia_lookup: take left at %d\n", node->bit); fprintf(stderr, "patricia_lookup: take left at %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
node = node->l; node = node->l;
} }
@ -654,7 +654,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
if(differ_bit > check_bit) if(differ_bit > check_bit)
differ_bit = check_bit; differ_bit = check_bit;
#ifdef PATRICIA_DEBUG #ifdef PATRICIA_DEBUG
fprintf(stderr, "patricia_lookup: differ_bit %d\n", differ_bit); fprintf(stderr, "patricia_lookup: differ_bit %u\n", differ_bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
parent = node->parent; parent = node->parent;
@ -667,7 +667,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
fprintf(stderr, "patricia_lookup: up to %s/%d\n", fprintf(stderr, "patricia_lookup: up to %s/%d\n",
prefix_toa(node->prefix), node->prefix->bitlen); prefix_toa(node->prefix), node->prefix->bitlen);
else else
fprintf(stderr, "patricia_lookup: up to %d\n", node->bit); fprintf(stderr, "patricia_lookup: up to %u\n", node->bit);
#endif /* PATRICIA_DEBUG */ #endif /* PATRICIA_DEBUG */
} }

View File

@ -124,7 +124,7 @@ int
rb_select_ports(long delay) rb_select_ports(long delay)
{ {
int i, fd; int i, fd;
int nget = 1; unsigned int nget = 1;
struct timespec poll_time; struct timespec poll_time;
struct timespec *p = NULL; struct timespec *p = NULL;
struct ev_entry *ev; struct ev_entry *ev;
@ -143,7 +143,7 @@ rb_select_ports(long delay)
if(i == -1) if(i == -1)
return RB_OK; return RB_OK;
for(i = 0; i < nget; i++) for(i = 0; (unsigned)i < nget; i++)
{ {
if(pelst[i].portev_source == PORT_SOURCE_FD) if(pelst[i].portev_source == PORT_SOURCE_FD)
{ {

View File

@ -32,7 +32,7 @@ skip_atoi(const char **s)
{ {
int i = 0; int i = 0;
while(isdigit(**s)) while(isdigit((unsigned char)**s))
i = i * 10 + *((*s)++) - '0'; i = i * 10 + *((*s)++) - '0';
return i; return i;
} }
@ -373,7 +373,7 @@ rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
/* get field width */ /* get field width */
field_width = -1; field_width = -1;
if(isdigit(*fmt)) if(isdigit((unsigned char)*fmt))
field_width = skip_atoi(&fmt); field_width = skip_atoi(&fmt);
else if(*fmt == '*') else if(*fmt == '*')
{ {
@ -392,7 +392,7 @@ rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
if(*fmt == '.') if(*fmt == '.')
{ {
++fmt; ++fmt;
if(isdigit(*fmt)) if(isdigit((unsigned char)*fmt))
precision = skip_atoi(&fmt); precision = skip_atoi(&fmt);
else if(*fmt == '*') else if(*fmt == '*')
{ {

View File

@ -223,7 +223,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char *
int t = AF_INET, ty, b; int t = AF_INET, ty, b;
const char *creason; const char *creason;
ty = parse_netmask(dlhost, (struct sockaddr *) &daddr, &b); ty = parse_netmask(dlhost, &daddr, &b);
if(ty == HM_HOST) if(ty == HM_HOST)
{ {
sendto_one(source_p, ":%s NOTICE %s :Invalid D-Line", me.name, source_p->name); sendto_one(source_p, ":%s NOTICE %s :Invalid D-Line", me.name, source_p->name);

View File

@ -724,7 +724,7 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
if(aconf == NULL && ConfigFileEntry.non_redundant_klines) if(aconf == NULL && ConfigFileEntry.non_redundant_klines)
{ {
bits = 0; bits = 0;
if((t = parse_netmask(lhost, (struct sockaddr *) &iphost, &bits)) != HM_HOST) if((t = parse_netmask(lhost, &iphost, &bits)) != HM_HOST)
{ {
#ifdef RB_IPV6 #ifdef RB_IPV6
if(t == HM_IPV6) if(t == HM_IPV6)

View File

@ -58,7 +58,7 @@ mapi_clist_av1 privs_clist[] = {
struct mode_table struct mode_table
{ {
const char *name; const char *name;
int mode; unsigned int mode;
}; };
/* there is no such table like this anywhere else */ /* there is no such table like this anywhere else */

View File

@ -412,7 +412,8 @@ stats_deny (struct Client *source_p)
static void static void
stats_exempt(struct Client *source_p) stats_exempt(struct Client *source_p)
{ {
char *name, *host, *pass, *user, *classname; char *name, *host, *user, *classname;
const char *pass;
struct AddressRec *arec; struct AddressRec *arec;
struct ConfItem *aconf; struct ConfItem *aconf;
int i, port; int i, port;
@ -523,7 +524,8 @@ stats_auth (struct Client *source_p)
else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p)) else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p))
{ {
struct ConfItem *aconf; struct ConfItem *aconf;
char *name, *host, *pass = "*", *user, *classname; char *name, *host, *user, *classname;
const char *pass = "*";
int port; int port;
if(MyConnect (source_p)) if(MyConnect (source_p))

View File

@ -57,7 +57,7 @@ DECLARE_MODULE_AV1(svinfo, NULL, NULL, svinfo_clist, NULL, NULL, "$Revision: 494
static int static int
ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{ {
signed int deltat; signed long deltat;
time_t theirtime; time_t theirtime;
char squitreason[120]; char squitreason[120];
@ -82,20 +82,20 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
*/ */
rb_set_time(); rb_set_time();
theirtime = atol(parv[4]); theirtime = atol(parv[4]);
deltat = abs(theirtime - rb_current_time()); deltat = labs(theirtime - rb_current_time());
if(deltat > ConfigFileEntry.ts_max_delta) if(deltat > ConfigFileEntry.ts_max_delta)
{ {
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s dropped, excessive TS delta" "Link %s dropped, excessive TS delta"
" (my TS=%ld, their TS=%ld, delta=%d)", " (my TS=%ld, their TS=%ld, delta=%ld)",
source_p->name, source_p->name,
(long) rb_current_time(), (long) theirtime, deltat); (long) rb_current_time(), (long) theirtime, deltat);
ilog(L_SERVER, ilog(L_SERVER,
"Link %s dropped, excessive TS delta" "Link %s dropped, excessive TS delta"
" (my TS=%ld, their TS=%ld, delta=%d)", " (my TS=%ld, their TS=%ld, delta=%ld)",
log_client_name(source_p, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat); log_client_name(source_p, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat);
rb_snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%d)", rb_snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%ld)",
(long) rb_current_time(), (long) theirtime, deltat); (long) rb_current_time(), (long) theirtime, deltat);
disable_server_conf_autoconn(source_p->name); disable_server_conf_autoconn(source_p->name);
exit_client(source_p, source_p, source_p, squitreason); exit_client(source_p, source_p, source_p, squitreason);
@ -106,7 +106,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
{ {
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Link %s notable TS delta" "Link %s notable TS delta"
" (my TS=%ld, their TS=%ld, delta=%d)", " (my TS=%ld, their TS=%ld, delta=%ld)",
source_p->name, (long) rb_current_time(), (long) theirtime, deltat); source_p->name, (long) rb_current_time(), (long) theirtime, deltat);
} }

View File

@ -120,7 +120,7 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
host = mask; host = mask;
/* parses as an IP, check for a dline */ /* parses as an IP, check for a dline */
if((type = parse_netmask(host, (struct sockaddr *)&ip, &host_mask)) != HM_HOST) if((type = parse_netmask(host, &ip, &host_mask)) != HM_HOST)
{ {
#ifdef RB_IPV6 #ifdef RB_IPV6
if(type == HM_IPV6) if(type == HM_IPV6)

View File

@ -36,7 +36,7 @@
#include "parse.h" #include "parse.h"
#include "modules.h" #include "modules.h"
static char *confopts(struct Client *source_p); static char *confopts(void);
static int m_version(struct Client *, struct Client *, int, const char **); static int m_version(struct Client *, struct Client *, int, const char **);
static int mo_version(struct Client *, struct Client *, int, const char **); static int mo_version(struct Client *, struct Client *, int, const char **);
@ -79,7 +79,7 @@ m_version(struct Client *client_p, struct Client *source_p, int parc, const char
#ifdef CUSTOM_BRANDING #ifdef CUSTOM_BRANDING
PACKAGE_NAME "-" PACKAGE_VERSION, PACKAGE_NAME "-" PACKAGE_VERSION,
#endif #endif
me.name, confopts(source_p), TS_CURRENT, me.name, confopts(), TS_CURRENT,
ServerInfo.sid); ServerInfo.sid);
show_isupport(source_p); show_isupport(source_p);
@ -101,7 +101,7 @@ mo_version(struct Client *client_p, struct Client *source_p, int parc, const cha
#ifdef CUSTOM_BRANDING #ifdef CUSTOM_BRANDING
PACKAGE_NAME "-" PACKAGE_VERSION, PACKAGE_NAME "-" PACKAGE_VERSION,
#endif #endif
me.name, confopts(source_p), TS_CURRENT, me.name, confopts(), TS_CURRENT,
ServerInfo.sid); ServerInfo.sid);
show_isupport(source_p); show_isupport(source_p);
} }
@ -110,12 +110,12 @@ mo_version(struct Client *client_p, struct Client *source_p, int parc, const cha
} }
/* confopts() /* confopts()
* input - client pointer * input - none
* output - ircd.conf option string * output - ircd.conf option string
* side effects - none * side effects - none
*/ */
static char * static char *
confopts(struct Client *source_p) confopts(void)
{ {
static char result[15]; static char result[15];
char *p; char *p;

View File

@ -221,7 +221,7 @@ bandb_check_kline(struct ConfItem *aconf)
int aftype; int aftype;
const char *p; const char *p;
aftype = parse_netmask(aconf->host, (struct sockaddr *)&daddr, NULL); aftype = parse_netmask(aconf->host, &daddr, NULL);
if(aftype != HM_HOST) if(aftype != HM_HOST)
{ {
@ -260,10 +260,9 @@ static int
bandb_check_dline(struct ConfItem *aconf) bandb_check_dline(struct ConfItem *aconf)
{ {
struct rb_sockaddr_storage daddr; struct rb_sockaddr_storage daddr;
/* struct ConfItem *dconf; */
int bits; int bits;
if(!parse_netmask(aconf->host, (struct sockaddr *)&daddr, &bits)) if(!parse_netmask(aconf->host, &daddr, &bits))
return 0; return 0;
return 1; return 1;

View File

@ -48,7 +48,7 @@ static unsigned long hash_ipv4(struct sockaddr *, int);
* Side effects: None * Side effects: None
*/ */
int int
parse_netmask(const char *text, struct sockaddr *naddr, int *nb) parse_netmask(const char *text, struct rb_sockaddr_storage *naddr, int *nb)
{ {
char *ip = LOCAL_COPY(text); char *ip = LOCAL_COPY(text);
char *ptr; char *ptr;
@ -60,9 +60,9 @@ parse_netmask(const char *text, struct sockaddr *naddr, int *nb)
b = nb; b = nb;
if(naddr == NULL) if(naddr == NULL)
addr = (struct rb_sockaddr_storage *)&xaddr; addr = &xaddr;
else else
addr = (struct rb_sockaddr_storage *)naddr; addr = naddr;
if(strpbrk(ip, "*?") != NULL) if(strpbrk(ip, "*?") != NULL)
{ {
@ -126,7 +126,7 @@ init_host_hash(void)
static unsigned long static unsigned long
hash_ipv4(struct sockaddr *saddr, int bits) hash_ipv4(struct sockaddr *saddr, int bits)
{ {
struct sockaddr_in *addr = (struct sockaddr_in *) saddr; struct sockaddr_in *addr = (struct sockaddr_in *)(void *)saddr;
if(bits != 0) if(bits != 0)
{ {
@ -146,7 +146,7 @@ hash_ipv4(struct sockaddr *saddr, int bits)
static unsigned long static unsigned long
hash_ipv6(struct sockaddr *saddr, int bits) hash_ipv6(struct sockaddr *saddr, int bits)
{ {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) saddr; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)(void *)saddr;
unsigned long v = 0, n; unsigned long v = 0, n;
for (n = 0; n < 16; n++) for (n = 0; n < 16; n++)
{ {
@ -484,7 +484,7 @@ find_exact_conf_by_address(const char *address, int type, const char *username)
if(address == NULL) if(address == NULL)
address = "/NOMATCH!/"; address = "/NOMATCH!/";
masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits); masktype = parse_netmask(address, &addr, &bits);
#ifdef RB_IPV6 #ifdef RB_IPV6
if(masktype == HM_IPV6) if(masktype == HM_IPV6)
{ {
@ -541,7 +541,7 @@ add_conf_by_address(const char *address, int type, const char *username, const c
if(address == NULL) if(address == NULL)
address = "/NOMATCH!/"; address = "/NOMATCH!/";
arec = rb_malloc(sizeof(struct AddressRec)); arec = rb_malloc(sizeof(struct AddressRec));
masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits); masktype = parse_netmask(address, &arec->Mask.ipa.addr, &bits);
arec->Mask.ipa.bits = bits; arec->Mask.ipa.bits = bits;
arec->masktype = masktype; arec->masktype = masktype;
#ifdef RB_IPV6 #ifdef RB_IPV6
@ -587,7 +587,7 @@ delete_one_address_conf(const char *address, struct ConfItem *aconf)
unsigned long hv; unsigned long hv;
struct AddressRec *arec, *arecl = NULL; struct AddressRec *arec, *arecl = NULL;
struct rb_sockaddr_storage addr; struct rb_sockaddr_storage addr;
masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits); masktype = parse_netmask(address, &addr, &bits);
#ifdef RB_IPV6 #ifdef RB_IPV6
if(masktype == HM_IPV6) if(masktype == HM_IPV6)
{ {
@ -741,7 +741,8 @@ show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
void void
report_auth(struct Client *client_p) report_auth(struct Client *client_p)
{ {
char *name, *host, *pass, *user, *classname; char *name, *host, *user, *classname;
const char *pass;
struct AddressRec *arec; struct AddressRec *arec;
struct ConfItem *aconf; struct ConfItem *aconf;
int i, port; int i, port;

View File

@ -331,14 +331,14 @@ int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask
if (addr->sa_family == AF_INET) if (addr->sa_family == AF_INET)
{ {
iaddr = &((struct sockaddr_in *)addr)->sin_addr; iaddr = &((struct sockaddr_in *)(void *)addr)->sin_addr;
idest = &((struct sockaddr_in *)dest)->sin_addr; idest = &((struct sockaddr_in *)(void *)dest)->sin_addr;
} }
#ifdef RB_IPV6 #ifdef RB_IPV6
else else
{ {
iaddr = &((struct sockaddr_in6 *)addr)->sin6_addr; iaddr = &((struct sockaddr_in6 *)(void *)addr)->sin6_addr;
idest = &((struct sockaddr_in6 *)dest)->sin6_addr; idest = &((struct sockaddr_in6 *)(void *)dest)->sin6_addr;
} }
#endif #endif

View File

@ -802,7 +802,7 @@ load_a_module(const char *path, int warn, int core)
{ {
case 1: case 1:
{ {
struct mapi_mheader_av1 *mheader = (struct mapi_mheader_av1 *) mapi_version; /* see above */ struct mapi_mheader_av1 *mheader = (struct mapi_mheader_av1 *)(void *)mapi_version; /* see above */
if(mheader->mapi_register && (mheader->mapi_register() == -1)) if(mheader->mapi_register && (mheader->mapi_register() == -1))
{ {
ilog(L_MAIN, "Module %s indicated failure during load.", ilog(L_MAIN, "Module %s indicated failure during load.",

View File

@ -1864,7 +1864,7 @@ conf_set_blacklist_matches(void *data)
/* Check for validity */ /* Check for validity */
if (*p == '.') if (*p == '.')
type = BLACKLIST_FILTER_ALL; type = BLACKLIST_FILTER_ALL;
else if (!isalnum(*p)) else if (!isalnum((unsigned char)*p))
{ {
conf_report_error("blacklist::matches has invalid IP match entry %s", conf_report_error("blacklist::matches has invalid IP match entry %s",
str); str);

View File

@ -49,7 +49,7 @@ struct Dictionary *alias_dict = NULL;
/* parv[0] is not used, and parv[LAST] == NULL */ /* parv[0] is not used, and parv[LAST] == NULL */
static char *para[MAXPARA + 2]; static char *para[MAXPARA + 2];
static void cancel_clients(struct Client *, struct Client *, char *); static void cancel_clients(struct Client *, struct Client *);
static void remove_unknown(struct Client *, char *, char *); static void remove_unknown(struct Client *, char *, char *);
static void do_numeric(char[], struct Client *, struct Client *, int, char **); static void do_numeric(char[], struct Client *, struct Client *, int, char **);
@ -169,7 +169,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
if(from->from != client_p) if(from->from != client_p)
{ {
ServerStats.is_wrdi++; ServerStats.is_wrdi++;
cancel_clients(client_p, from, pbuffer); cancel_clients(client_p, from);
return; return;
} }
} }
@ -269,7 +269,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
return; return;
} }
if(handle_command(mptr, client_p, from, i, /* XXX discards const!!! */ (const char **)para) < -1) if(handle_command(mptr, client_p, from, i, /* XXX discards const!!! */ (const char **)(void *)para) < -1)
{ {
char *p; char *p;
for (p = pbuffer; p <= end; p += 8) for (p = pbuffer; p <= end; p += 8)
@ -489,12 +489,12 @@ report_messages(struct Client *source_p)
/* cancel_clients() /* cancel_clients()
* *
* inputs - client who sent us the message, client with fake * inputs - client who sent us the message, client with fake
* direction, command * direction
* outputs - a given warning about the fake direction * outputs - a given warning about the fake direction
* side effects - * side effects -
*/ */
static void static void
cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd) cancel_clients(struct Client *client_p, struct Client *source_p)
{ {
/* ok, fake prefix happens naturally during a burst on a nick /* ok, fake prefix happens naturally during a burst on a nick
* collision with TS5, we cant kill them because one client has to * collision with TS5, we cant kill them because one client has to

View File

@ -29,7 +29,7 @@
#include "logger.h" #include "logger.h"
#include "send.h" #include "send.h"
static rb_dlink_list privilegeset_list = {}; static rb_dlink_list privilegeset_list = {NULL, NULL, 0};
int int
privilegeset_in_set(struct PrivilegeSet *set, const char *priv) privilegeset_in_set(struct PrivilegeSet *set, const char *priv)

View File

@ -552,7 +552,7 @@ static void query_name(struct reslist *request)
if ((request_len = if ((request_len =
irc_res_mkquery(request->queryname, C_IN, request->type, (unsigned char *)buf, sizeof(buf))) > 0) irc_res_mkquery(request->queryname, C_IN, request->type, (unsigned char *)buf, sizeof(buf))) > 0)
{ {
HEADER *header = (HEADER *) buf; HEADER *header = (HEADER *)(void *)buf;
header->id = request->id; header->id = request->id;
++request->sends; ++request->sends;
@ -784,7 +784,7 @@ static int res_read_single_reply(rb_fde_t *F, void *data)
/* /*
* convert DNS reply reader from Network byte order to CPU byte order. * convert DNS reply reader from Network byte order to CPU byte order.
*/ */
header = (HEADER *) buf; header = (HEADER *)(void *)buf;
header->ancount = ntohs(header->ancount); header->ancount = ntohs(header->ancount);
header->qdcount = ntohs(header->qdcount); header->qdcount = ntohs(header->qdcount);
header->nscount = ntohs(header->nscount); header->nscount = ntohs(header->nscount);

View File

@ -478,7 +478,7 @@ irc_ns_name_ntop(const char *src, char *dst, size_t dstsiz)
*/ */
static int static int
irc_dn_comp(const char *src, unsigned char *dst, int dstsiz, irc_dn_comp(const char *src, unsigned char *dst, int dstsiz,
unsigned char **dnptrs, unsigned char **lastdnptr) const unsigned char **dnptrs, const unsigned char **lastdnptr)
{ {
return(irc_ns_name_compress(src, dst, (size_t)dstsiz, return(irc_ns_name_compress(src, dst, (size_t)dstsiz,
(const unsigned char **)dnptrs, (const unsigned char **)dnptrs,
@ -1145,7 +1145,7 @@ irc_res_mkquery(
HEADER *hp; HEADER *hp;
unsigned char *cp; unsigned char *cp;
int n; int n;
unsigned char *dnptrs[20], **dpp, **lastdnptr; const unsigned char *dnptrs[20], **dpp, **lastdnptr;
/* /*
* Initialize header fields. * Initialize header fields.
@ -1153,7 +1153,7 @@ irc_res_mkquery(
if ((buf == NULL) || (buflen < HFIXEDSZ)) if ((buf == NULL) || (buflen < HFIXEDSZ))
return (-1); return (-1);
memset(buf, 0, HFIXEDSZ); memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf; hp = (HEADER *)(void *)buf;
hp->id = 0; hp->id = 0;
hp->opcode = QUERY; hp->opcode = QUERY;

View File

@ -75,7 +75,7 @@ rb_dlink_list service_list;
/* internally defined functions */ /* internally defined functions */
static void set_default_conf(void); static void set_default_conf(void);
static void validate_conf(void); static void validate_conf(void);
static void read_conf(FILE *); static void read_conf(void);
static void clear_out_old_conf(void); static void clear_out_old_conf(void);
static void expire_prop_bans(void *list); static void expire_prop_bans(void *list);
@ -818,12 +818,12 @@ set_default_conf(void)
* read_conf() * read_conf()
* *
* *
* inputs - file descriptor pointing to config file to use * inputs - None
* output - None * output - None
* side effects - Read configuration file. * side effects - Read configuration file.
*/ */
static void static void
read_conf(FILE * file) read_conf(void)
{ {
lineno = 0; lineno = 0;
@ -1280,7 +1280,7 @@ get_oper_name(struct Client *client_p)
*/ */
void void
get_printable_conf(struct ConfItem *aconf, char **name, char **host, get_printable_conf(struct ConfItem *aconf, char **name, char **host,
char **pass, char **user, int *port, char **classname) const char **pass, char **user, int *port, char **classname)
{ {
static char null[] = "<NULL>"; static char null[] = "<NULL>";
static char zero[] = "default"; static char zero[] = "default";
@ -1399,7 +1399,7 @@ read_conf_files(int cold)
} }
call_hook(h_conf_read_start, NULL); call_hook(h_conf_read_start, NULL);
read_conf(conf_fbfile_in); read_conf();
call_hook(h_conf_read_end, NULL); call_hook(h_conf_read_end, NULL);
fclose(conf_fbfile_in); fclose(conf_fbfile_in);

View File

@ -291,7 +291,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const
int bits, cbits; int bits, cbits;
rb_dlink_node *ptr; rb_dlink_node *ptr;
parse_netmask(locip, (struct sockaddr *)&cip, &cbits); parse_netmask(locip, &cip, &cbits);
RB_DLINK_FOREACH(ptr, oper_conf_list.head) RB_DLINK_FOREACH(ptr, oper_conf_list.head)
{ {
@ -303,7 +303,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const
rb_strlcpy(addr, oper_p->host, sizeof(addr)); rb_strlcpy(addr, oper_p->host, sizeof(addr));
if(parse_netmask(addr, (struct sockaddr *)&ip, &bits) != HM_HOST) if(parse_netmask(addr, &ip, &bits) != HM_HOST)
{ {
if(ip.ss_family == cip.ss_family && if(ip.ss_family == cip.ss_family &&
comp_with_mask_sock((struct sockaddr *)&ip, (struct sockaddr *)&cip, bits)) comp_with_mask_sock((struct sockaddr *)&ip, (struct sockaddr *)&cip, bits))

View File

@ -578,7 +578,7 @@ burst_TS6(struct Client *client_p)
if(!IsPerson(target_p)) if(!IsPerson(target_p))
continue; continue;
send_umode(NULL, target_p, 0, 0, ubuf); send_umode(NULL, target_p, 0, ubuf);
if(!*ubuf) if(!*ubuf)
{ {
ubuf[0] = '+'; ubuf[0] = '+';

View File

@ -599,9 +599,9 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
hook_data_client hdata2; hook_data_client hdata2;
if(MyClient(source_p)) if(MyClient(source_p))
send_umode(source_p, source_p, 0, 0, ubuf); send_umode(source_p, source_p, 0, ubuf);
else else
send_umode(NULL, source_p, 0, 0, ubuf); send_umode(NULL, source_p, 0, ubuf);
if(!*ubuf) if(!*ubuf)
{ {
@ -1155,7 +1155,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
* -avalon * -avalon
*/ */
void void
send_umode(struct Client *client_p, struct Client *source_p, int old, int sendmask, char *umode_buf) send_umode(struct Client *client_p, struct Client *source_p, int old, char *umode_buf)
{ {
int i; int i;
int flag; int flag;
@ -1216,7 +1216,7 @@ send_umode_out(struct Client *client_p, struct Client *source_p, int old)
char buf[BUFSIZE]; char buf[BUFSIZE];
rb_dlink_node *ptr; rb_dlink_node *ptr;
send_umode(NULL, source_p, old, 0, buf); send_umode(NULL, source_p, old, buf);
RB_DLINK_FOREACH(ptr, serv_list.head) RB_DLINK_FOREACH(ptr, serv_list.head)
{ {
@ -1231,7 +1231,7 @@ send_umode_out(struct Client *client_p, struct Client *source_p, int old)
} }
if(client_p && MyClient(client_p)) if(client_p && MyClient(client_p))
send_umode(client_p, source_p, old, 0, buf); send_umode(client_p, source_p, old, buf);
} }
/* /*

View File

@ -91,23 +91,6 @@ int32_to_buf(char *buf, int32_t x)
return; return;
} }
static inline uint16_t
buf_to_uint16(char *buf)
{
uint16_t x;
memcpy(&x, buf, sizeof(x));
return x;
}
static inline void
uint16_to_buf(char *buf, uint16_t x)
{
memcpy(buf, &x, sizeof(x));
return;
}
static ssl_ctl_t * static ssl_ctl_t *
allocate_ssl_daemon(rb_fde_t * F, rb_fde_t * P, int pid) allocate_ssl_daemon(rb_fde_t * F, rb_fde_t * P, int pid)
{ {

View File

@ -51,22 +51,6 @@ int32_to_buf(uint8_t *buf, int32_t x)
return; return;
} }
static inline uint16_t
buf_to_uint16(uint8_t *buf)
{
uint16_t x;
memcpy(&x, buf, sizeof(x));
return x;
}
static inline void
uint16_to_buf(uint8_t *buf, uint16_t x)
{
memcpy(buf, &x, sizeof(x));
return;
}
static char inbuf[READBUF_SIZE]; static char inbuf[READBUF_SIZE];
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
static char outbuf[READBUF_SIZE]; static char outbuf[READBUF_SIZE];

View File

@ -55,9 +55,6 @@ static void brief_usage(void);
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/* 0 .. 63, ascii - 64 */ /* 0 .. 63, ascii - 64 */
extern char *optarg;
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <conio.h> #include <conio.h>
#ifdef PASS_MAX #ifdef PASS_MAX
@ -72,7 +69,7 @@ getpass(const char *prompt)
int c; int c;
int i = 0; int i = 0;
memset(getpassbuf, sizeof(getpassbuf), 0); memset(getpassbuf, 0, sizeof(getpassbuf));
fputs(prompt, stderr); fputs(prompt, stderr);
for(;;) for(;;)
{ {