Author: Bleep <tomh@inxpress.net>
authorBleep <twhelvey1@home.com>
Sat, 15 Apr 2000 04:20:14 +0000 (04:20 +0000)
committerBleep <twhelvey1@home.com>
Sat, 15 Apr 2000 04:20:14 +0000 (04:20 +0000)
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

16 files changed:
BUGS
ChangeLog
TODO
include/fda.h
include/s_conf.h
include/s_serv.h
ircd/IPcheck.c
ircd/ircd_snprintf.c
ircd/m_error.c
ircd/m_user.c
ircd/m_whois.c
ircd/res.c
ircd/s_bsd.c
ircd/s_conf.c
ircd/s_serv.c
ircd/version.c.SH

diff --git a/BUGS b/BUGS
index e45c008a41efbe1e5ebdfab004c614ec591ef46f..473ae52e77370a485b777bf429dd8a5c16548ede 100644 (file)
--- 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
index 21fc07e44bc5fc4047f52032e1fbeb78c915e141..1d53b4fe6c9d4678b7ce86d2733c2c51761bc97e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2000-04-15  Thomas Helvey <tomh@inxpress.net>
+
+       * 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 <gte@atomicrevs.demon.co.uk>
 
        * ircd/userload.c: change <sys/time.h> include to <time.h> for
 #
 # 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 9de3e180d9eb58a7a78bb6ce6fea514725ef98f9..3dfdcfe0fe1b63f45c3400db9be3ea52b5ccd71d 100644 (file)
--- 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)
index 379534e9cc9354687fd5b293ee360d1cb4a85ba9..a8f465c5e31b85b495953dba279c0c17b8866593 100644 (file)
 #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 */
index 118ce0eb60b3b26727dd75475457b62f4f425944..6d3f7f124fe86468bef9c40c7602e65c8dc67fca 100644 (file)
@@ -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, 
index e0785730d3f8ae8233499a36c70c291474d849f2..189105ce59a56e9743e5345c21bc624696e20df2 100644 (file)
@@ -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);
 
index ac9b0c6799e890d95b883b34064babea38d3c6a8..fb9823899ddc8344f81de880a0037515e78632bf 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <assert.h>
 #include <stdio.h>          /* NULL ... bleah */
+#include <string.h>         /* memset */
 
 
 struct IPTargetEntry {
index fa3e7cae5e492233c1dbe84268dfb59710509d24..d3ba6f03c648e7b8c9a8106116b6e0cbf67d4d2e 100644 (file)
@@ -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 */
index f981a6627b1114c8feeaa3d6a3bcc8b4fa019b82..85e6befec9abff7039b4321b540098b0ecf49bd0 100644 (file)
  */
 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] : "<>";
 
index 6513b93423133fecc97eb147706a6a3160ffd498..ee7325ec7af7c52aabd61da7f67d67acefd23a19 100644 (file)
 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);
index f99df5c58cab2d522e39d5c58e228d36548a8064..e36325b115a5888b7e52d9dfcfd257284ff60041 100644 (file)
@@ -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;
index b3f81077209e3779ed18666c036d5a09c0476288..ceeacb93a9429f73d6c6e50bb728760ee0104453 100644 (file)
@@ -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)) {
index d46cb1b5e92d590d2f8244df69e4e1f8931748ce..42138437941cfefb46fc335bfe39f194b0d8a147 100644 (file)
@@ -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
index 9be42947a0d05bd1c639a5fe2ba71daaf17b98d9..ede47705478a5e0e9f56f3301a6dcba5c5030407 100644 (file)
@@ -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);
 
index a2912b597b3a1305574ce63c57873df26d2733c8..4cb3459cc6c9ca9354e6e5116f2048c420f2343d 100644 (file)
@@ -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 =
index 8f0ff42708e6e5d0b80cb39ced42fa139983b0a8..e7841b23fa925695f46d325eee42b383386c5c99 100644 (file)
@@ -83,9 +83,9 @@ const char *infotext[] = {
     "Bleep        Thomas Helvey            <tomh@inxpress.net>",
     "",
     "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"
     "",