From: Matthew Mondor Date: Sat, 27 Aug 2016 15:09:03 +0000 (+0000) Subject: ANSI and 64-bit related cleanup - integer-pointer mismatch X-Git-Tag: rubiks-ircd-1-0-6~5 X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=3da3566cc76ab015f2f0f43341fe17f1d2630eb7;p=rubiks-ircd.git ANSI and 64-bit related cleanup - integer-pointer mismatch Compiled with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast and fixed build-breaking cases. Another common segfault candidate on x86_64. --- diff --git a/TODO b/TODO index 5ffbfcb..b3c494c 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ ANSI fixes ---------- -- Compile with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast - Fix any function arg mismatch (use -Werror=) (too many arg) - Fix format argument related warnings - Recheck warnings with -Wall diff --git a/src/clientlist.c b/src/clientlist.c index 6f711ba..96402c5 100644 --- a/src/clientlist.c +++ b/src/clientlist.c @@ -103,5 +103,5 @@ void remove_from_list(DLink **list, void *ptr, DLink *link) } } - sendto_realops("remove_from_list(%x, %x) failed!!", (int) list, (int) ptr); + sendto_realops("remove_from_list(%p, %p) failed!!", list, ptr); } diff --git a/src/ircd.c b/src/ircd.c index 10502b0..319caca 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -213,8 +214,8 @@ void restart(char *mesg) was_here = YES; #ifdef USE_SYSLOG - (void) syslog(LOG_WARNING, "Restarting Server because: %s, sbrk(0)-etext: %d", - mesg, (u_int) sbrk((size_t) 0) - (u_int) sbrk0); + (void) syslog(LOG_WARNING, "Restarting Server because: %s, sbrk(0)-etext: %lld", + mesg, (intptr_t)sbrk((size_t)0) - (intptr_t)sbrk0); #endif server_reboot(); } @@ -237,9 +238,9 @@ void s_restart() void server_reboot() { int i; - sendto_ops("Aieeeee!!! Restarting server... sbrk(0)-etext: %d", - (u_int) sbrk((size_t) 0) - (u_int) sbrk0); - + sendto_ops("Aieeeee!!! Restarting server... sbrk(0)-etext: %lld", + (intptr_t)sbrk((size_t)0) - (intptr_t)sbrk0); + Debug((DEBUG_NOTICE, "Restarting server...")); dump_connections(me.fd); /* diff --git a/src/m_stats.c b/src/m_stats.c index b31030b..8abd78e 100644 --- a/src/m_stats.c +++ b/src/m_stats.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "h.h" #include "zlink.h" #include "userban.h" @@ -706,9 +707,9 @@ count_memory(aClient *cptr, char *nick) me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, totmisc, /*db,*/ tothash, rm, linkallocsz, fludallocsz, totuban); - sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %u", + sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %lld", me.name, RPL_STATSDEBUG, nick, tot, - (u_int) sbrk((size_t) 0) - (u_int) sbrk0); + (intptr_t)sbrk((size_t)0) - (intptr_t)sbrk0); return; } diff --git a/src/modules.c b/src/modules.c index 54dbbdd..9f25247 100644 --- a/src/modules.c +++ b/src/modules.c @@ -643,8 +643,8 @@ drop_all_hooks(aModule *owner) if(hk->owner == owner) { sendto_realops_lev(DEBUG_LEV, "Module cleanup: removing hook [%s]" - " for opaque %d", get_texthooktype(hk->hooktype), - (int) owner); + " for opaque %p", get_texthooktype(hk->hooktype), + owner); hooklist = get_hooklist((enum c_hooktype) hk->hooktype); @@ -665,7 +665,7 @@ bircmodule_add_hook(enum c_hooktype hooktype, void *opaque, void *funcptr) if(!(owner = find_module_opaque(opaque))) { sendto_realops_lev(DEBUG_LEV, "Module tried to add hooktype %d with" - " unknown opaque 0x%x", (int) hooktype, (int) opaque); + " unknown opaque %p", (int) hooktype, opaque); return NULL; } diff --git a/src/res.c b/src/res.c index bd53a8c..2618235 100644 --- a/src/res.c +++ b/src/res.c @@ -1440,7 +1440,7 @@ static unsigned int hash_id(unsigned int id) static unsigned int hash_cp(char *cp) { - return ((unsigned int) cp) % ARES_IDCACSIZE; + return (unsigned int)((intptr_t)cp) % ARES_IDCACSIZE; } /* Add a new cache item to the queue and hash table. */ diff --git a/src/socketengine_poll.c b/src/socketengine_poll.c index 25106ca..3a369b9 100644 --- a/src/socketengine_poll.c +++ b/src/socketengine_poll.c @@ -16,11 +16,12 @@ #include "socketengine.h" #include +#include static void engine_get_pollfds(struct pollfd **pfds, int *numpfds); struct pollfd poll_fds[MAXCONNECTIONS]; -int last_pfd = -1; +intptr_t last_pfd = -1; void engine_init(void) { @@ -43,7 +44,7 @@ void engine_add_fd(int fd) void engine_del_fd(int fd) { - int arrayidx = (int) get_fd_internal(fd); + intptr_t arrayidx = (intptr_t)get_fd_internal(fd); /* If it's at the end of the array, just chop it off */ if(arrayidx == last_pfd) @@ -63,7 +64,7 @@ void engine_del_fd(int fd) void engine_change_fd_state(int fd, unsigned int stateplus) { - int arrayidx = (int) get_fd_internal(fd); + intptr_t arrayidx = (intptr_t)get_fd_internal(fd); struct pollfd *pfd = &poll_fds[arrayidx]; pfd->events = 0;