From: Bleep Date: Sat, 15 Apr 2000 04:20:14 +0000 (+0000) Subject: Author: Bleep X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=c43766a3bc1fb2102600a758b30423e06e5f7df4;p=ircu2.10.12-pk.git Author: Bleep Log message: Type safety and const correctness cleanups. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@180 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/BUGS b/BUGS index e45c008..473ae52 100644 --- a/BUGS +++ b/BUGS @@ -1,7 +1,8 @@ # # BUGS file for ircu2.10 # -# $Id: BUGS,v 1.5 2000-04-14 17:08:06 kev Exp $ +# $Id: BUGS,v 1.6 2000-04-15 04:20:14 bleep Exp $ # +* crule parser coredumps on invalid input * /mode #foo +o Thisnickdoesntexist -> Core dump. Kev? - FIXED diff --git a/ChangeLog b/ChangeLog index 21fc07e..1d53b4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-04-15 Thomas Helvey + + * ircd/*.c: const correctness and type safety cleanups to + get code to compile with C++ compiler. Still has + signed/unsigned comparison warnings. + 2000-04-15 Greg Sikorski * ircd/userload.c: change include to for @@ -536,7 +542,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.88 2000-04-15 03:47:32 gte Exp $ +# $Id: ChangeLog,v 1.89 2000-04-15 04:20:14 bleep Exp $ # # Insert new changes at beginning of the change list. # diff --git a/TODO b/TODO index 9de3e18..3dfdcfe 100644 --- a/TODO +++ b/TODO @@ -15,6 +15,7 @@ High Priority: (No idea) Medium Priority: +* crule parser coredumps on invalid input * why do the allocation counts change the first time you rehash after a server boot without changing the conf file: *** Allocations: 416(41848) diff --git a/include/fda.h b/include/fda.h index 379534e..a8f465c 100644 --- a/include/fda.h +++ b/include/fda.h @@ -28,10 +28,6 @@ #endif -#ifdef __cplusplus -extern "C" { -#endif - extern size_t fda_get_byte_count(void); extern size_t fda_get_block_count(void); extern size_t fda_sizeof(const void* p); @@ -61,9 +57,6 @@ extern void fda_free(void* p); extern void fda_set_lowmem_handler(void (*fn)(void)); extern void fda_set_nomem_handler(void (*fn)(void)); -#ifdef __cplusplus -} -#endif #endif /* !defined(NDEBUG) */ #endif /* INCLUDED_fda_h */ diff --git a/include/s_conf.h b/include/s_conf.h index 118ce0e..6d3f7f1 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -120,9 +120,8 @@ extern struct ConfItem* conf_find_server(const char* name); const char* conf_eval_crule(struct ConfItem* conf); extern void det_confs_butmask(struct Client *cptr, int mask); -extern int attach_iline(struct Client *cptr); extern int detach_conf(struct Client *cptr, struct ConfItem *aconf); -extern int attach_conf(struct Client *cptr, struct ConfItem *aconf); +extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf); extern struct ConfItem* find_admin(void); extern struct ConfItem* find_me(void); extern struct ConfItem* find_conf_exact(const char* name, diff --git a/include/s_serv.h b/include/s_serv.h index e078573..189105c 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -20,8 +20,8 @@ extern unsigned int max_client_count; /* * Prototypes */ -extern int exit_new_server(struct Client *cptr, struct Client *sptr, - char *host, time_t timestamp, char *fmt, ...); +extern int exit_new_server(struct Client* cptr, struct Client* sptr, + const char* host, time_t timestamp, const char* fmt, ...); extern int a_kills_b_too(struct Client *a, struct Client *b); extern int server_estab(struct Client *cptr, struct ConfItem *aconf); diff --git a/ircd/IPcheck.c b/ircd/IPcheck.c index ac9b0c6..fb98238 100644 --- a/ircd/IPcheck.c +++ b/ircd/IPcheck.c @@ -31,6 +31,7 @@ #include #include /* NULL ... bleah */ +#include /* memset */ struct IPTargetEntry { diff --git a/ircd/ircd_snprintf.c b/ircd/ircd_snprintf.c index fa3e7ca..d3ba6f0 100644 --- a/ircd/ircd_snprintf.c +++ b/ircd/ircd_snprintf.c @@ -1927,7 +1927,7 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt, } else if ((fld_s.flags & CONV_MASK) == CONV_STRING || fld_s.value.v_ptr == 0) { /* spaces or null pointers */ int slen, plen; - char *str = fld_s.value.v_ptr; + char *str = (char*) fld_s.value.v_ptr; if (!str) /* NULL pointers print "(null)" */ str = "(null)"; @@ -1944,7 +1944,7 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt, do_pad(buf_p, plen, spaces); /* post-padding */ } else if ((fld_s.flags & CONV_MASK) == CONV_VARARGS) { struct BufData buf_s = BUFDATA_INIT; - struct VarData *vdata = fld_s.value.v_ptr; + struct VarData *vdata = (struct VarData*) fld_s.value.v_ptr; int plen, tlen; buf_s.buf = buf_p->buf + buf_p->buf_loc; @@ -1992,7 +1992,7 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt, vdata->vd_chars = buf_s.buf_loc; /* return relevant data */ vdata->vd_overflow = SNP_MAX(buf_s.buf_overflow, buf_s.overflow); } else if ((fld_s.flags & CONV_MASK) == CONV_CLIENT) { - struct Client *cptr = fld_s.value.v_ptr; + struct Client *cptr = (struct Client*) fld_s.value.v_ptr; char *str1 = 0, *str2 = 0; int slen1 = 0, slen2 = 0, plen = 0; @@ -2038,6 +2038,9 @@ ircd_snprintf(struct Client *dest, char *buf, size_t buf_len, buf_s.buf = buf; /* initialize buffer settings */ buf_s.buf_size = buf_len - 1; + /* + * XXX - assignment of -1 to size_t + */ buf_s.limit = -1; va_start(args, format); @@ -2060,6 +2063,9 @@ ircd_vsnprintf(struct Client *dest, char *buf, size_t buf_len, buf_s.buf = buf; /* initialize buffer settings */ buf_s.buf_size = buf_len - 1; + /* + * XXX - assignment of -1 to size_t + */ buf_s.limit = -1; doprintf(dest, &buf_s, format, args); /* fill the buffer */ diff --git a/ircd/m_error.c b/ircd/m_error.c index f981a66..85e6bef 100644 --- a/ircd/m_error.c +++ b/ircd/m_error.c @@ -109,7 +109,7 @@ */ int ms_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - char *para; + const char *para; para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>"; @@ -147,7 +147,7 @@ int ms_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ int mr_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - char *para; + const char *para; para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>"; diff --git a/ircd/m_user.c b/ircd/m_user.c index 6513b93..ee7325e 100644 --- a/ircd/m_user.c +++ b/ircd/m_user.c @@ -118,9 +118,9 @@ int m_user(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { char* username; - char* umode; - char* snomask; - char* info; + const char* umode; + const char* snomask; + const char* info; struct User* user; assert(0 != cptr); diff --git a/ircd/m_whois.c b/ircd/m_whois.c index f99df5c..e36325b 100644 --- a/ircd/m_whois.c +++ b/ircd/m_whois.c @@ -123,7 +123,7 @@ int m_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct Channel* chptr; char* nick; char* tmp; - char* name; + const char* name; char* p = 0; int found; int len; @@ -337,7 +337,7 @@ int ms_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct Channel* chptr; char* nick; char* tmp; - char* name; + const char* name; char* p = 0; int found; int len; @@ -551,7 +551,7 @@ int mo_whois(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) struct Channel* chptr; char* nick; char* tmp; - char* name; + const char* name; char* p = 0; int found; int len; diff --git a/ircd/res.c b/ircd/res.c index b3f8107..ceeacb9 100644 --- a/ircd/res.c +++ b/ircd/res.c @@ -682,7 +682,7 @@ static void query_name(const char* name, int query_class, Debug((DEBUG_DNS, "Resolver: query_name: %s %d %d", name, query_class, type)); memset(buf, 0, sizeof(buf)); if ((request_len = res_mkquery(QUERY, name, query_class, type, - NULL, 0, NULL, buf, sizeof(buf))) > 0) { + 0, 0, 0, (unsigned char*) buf, sizeof(buf))) > 0) { HEADER* header = (HEADER*) buf; #ifndef LRAND48 int k = 0; @@ -709,7 +709,7 @@ static void query_name(const char* name, int query_class, ++request->sends; Debug((DEBUG_DNS, "Resolver: query_name %d: %s %d %d", request->id, name, query_class, type)); - request->sent += send_res_msg(buf, request_len, request->sends); + request->sent += send_res_msg((const unsigned char*) buf, request_len, request->sends); } } @@ -963,7 +963,7 @@ int resolver_read(void) Debug((DEBUG_DNS, "Resolver: read")); if (IO_SUCCESS != os_recvfrom_nonb(ResolverFileDescriptor, - buf, sizeof(buf), &rc, &sin)) { + (char*) buf, sizeof(buf), &rc, &sin)) { return 0; } if (rc < sizeof(HEADER)) { @@ -1359,7 +1359,7 @@ static struct CacheEntry* add_to_cache(struct CacheEntry* ocp) ocp->hname_next = hashtable[hashv].name_list; hashtable[hashv].name_list = ocp; - hashv = hash_number(ocp->he.h.h_addr); + hashv = hash_number((const unsigned char*) ocp->he.h.h_addr); ocp->hnum_next = hashtable[hashv].num_list; hashtable[hashv].num_list = ocp; @@ -1504,7 +1504,7 @@ static struct CacheEntry* find_cache_number(struct ResRequest* request, int i; assert(0 != addr); - hashv = hash_number(addr); + hashv = hash_number((const unsigned char*) addr); cp = hashtable[hashv].num_list; for (; cp; cp = cp->hnum_next) { @@ -1523,7 +1523,7 @@ static struct CacheEntry* find_cache_number(struct ResRequest* request, * are looking for, its been done already. */ if (!cp->he.h.h_addr_list[1] || - hashv == hash_number(cp->he.h.h_addr_list[0])) + hashv == hash_number((const unsigned char*) cp->he.h.h_addr_list[0])) continue; for (i = 1; cp->he.h.h_addr_list[i]; ++i) { if (!memcmp(cp->he.h.h_addr_list[i], addr, sizeof(struct in_addr))) { @@ -1628,7 +1628,7 @@ static void rem_cache(struct CacheEntry* ocp) /* * remove cache entry from hashed number list */ - hashv = hash_number(hp->h_addr); + hashv = hash_number((const unsigned char*) hp->h_addr); assert(-1 < hashv); for (cp = &hashtable[hashv].num_list; *cp; cp = &((*cp)->hnum_next)) { diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index d46cb1b..4213843 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -583,7 +583,7 @@ void add_connection(struct Listener* listener, int fd) return; } - new_client = make_client(NULL, + new_client = make_client(0, (listener->server) ? STAT_UNKNOWN_SERVER : STAT_UNKNOWN_USER); /* * Copy ascii address to 'sockhost' just in case. Then we diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 9be4294..ede4770 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -491,7 +491,8 @@ static int validate_hostent(struct hostent* hp) /* * check_limit_and_attach - check client limits and attach I:line */ -static int check_limit_and_attach(struct Client* cptr, struct ConfItem* aconf) +static enum AuthorizationCheckResult +check_limit_and_attach(struct Client* cptr, struct ConfItem* aconf) { if (aconf->passwd) { /* Special case: exactly one digit */ @@ -521,7 +522,7 @@ static int check_limit_and_attach(struct Client* cptr, struct ConfItem* aconf) /* * Find the first (best) I line to attach. */ -int attach_iline(struct Client* cptr) +enum AuthorizationCheckResult attach_iline(struct Client* cptr) { struct ConfItem* aconf; const char* hname; @@ -634,7 +635,7 @@ static int is_attached(struct ConfItem *aconf, struct Client *cptr) * connection). Note, that this automaticly changes the * attachment if there was an old one... */ -int attach_conf(struct Client *cptr, struct ConfItem *aconf) +enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf) { struct SLink *lp; @@ -1500,7 +1501,7 @@ struct MotdItem* read_motd(const char* motdfile) */ enum AuthorizationCheckResult conf_check_client(struct Client *cptr) { - int acr; + enum AuthorizationCheckResult acr = ACR_OK; ClearAccess(cptr); diff --git a/ircd/s_serv.c b/ircd/s_serv.c index a2912b5..4cb3459 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -60,8 +60,8 @@ unsigned int max_connection_count = 0; unsigned int max_client_count = 0; -int exit_new_server(struct Client *cptr, struct Client *sptr, - char *host, time_t timestamp, char *fmt, ...) +int exit_new_server(struct Client* cptr, struct Client* sptr, + const char* host, time_t timestamp, const char* fmt, ...) { va_list vl; char *buf = diff --git a/ircd/version.c.SH b/ircd/version.c.SH index 8f0ff42..e7841b2 100644 --- a/ircd/version.c.SH +++ b/ircd/version.c.SH @@ -83,9 +83,9 @@ const char *infotext[] = { "Bleep Thomas Helvey ", "", "Contributors to this release:", - "Isomer, Gte-, WildThang, David M, Run, Nemesi", + "Kev, Isomer, Gte, Ghostwolf, Bleep", "Debugging and support:", - "SeKs, Maniac-, HeKTik, OmniDynmc, Aurorian, Quantum, Jesus", + "SeKs, Maniac-, HeKTik, OmniDynmc, Liandrin, Dianora", "Special thanks to Angel and Buff for believing in us and putting" "up with frantic late night phone calls" "",