From: Nathan Bryant Date: Wed, 17 Oct 2001 19:40:39 +0000 (+0000) Subject: warning fixes and cleanups for 64-bit machines X-Git-Tag: v7.86~6749 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1f79d7b9a6f60f331ea0c90e9eb4ef7c40ee7aa5 warning fixes and cleanups for 64-bit machines --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 2e8c5e733..f50f3c0f4 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 580.64 2001/10/17 19:40:38 nbryant + warning fixes and cleanups for 64-bit machines + Revision 580.63 2001/10/16 20:47:37 nbryant - backed out -export-dynamic, it doesn't do anything and i've found the real problem @@ -2821,3 +2824,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/aidepost.c b/citadel/aidepost.c index 1d38d92ef..37d1a295e 100644 --- a/citadel/aidepost.c +++ b/citadel/aidepost.c @@ -25,6 +25,11 @@ #include "citadel.h" #include "config.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + + static void make_message(FILE *fp, char *target_room, char *author) { int a; diff --git a/citadel/citserver.c b/citadel/citserver.c index 57fe8e98b..3d83bfe8c 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -57,6 +57,10 @@ #include "control.h" #include "tools.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + struct CitContext *ContextList = NULL; char *unique_session_numbers; int ScheduledShutdown = 0; diff --git a/citadel/configure.ac b/citadel/configure.ac index cc8f0e3e9..776c40d1e 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -92,11 +92,11 @@ AC_PROG_CC dnl Set up system-dependent compiler flags. if test "$GCC" = yes; then case "$host" in - *-*-solaris*) - CFLAGS="$CFLAGS -Wall -Wno-char-subscripts" + *-*-solaris*|alpha*-dec-osf*) + CFLAGS="$CFLAGS -Wall -Wcast-align -Wno-char-subscripts" ;; *) - CFLAGS="$CFLAGS -Wall -Wstrict-prototypes" + CFLAGS="$CFLAGS -Wall -Wcast-align -Wstrict-prototypes" ;; esac fi diff --git a/citadel/control.c b/citadel/control.c index fd44e0905..c1a34fbc4 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -45,6 +45,10 @@ #include "tools.h" #include "room_ops.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + struct CitControl CitControl; struct config config; FILE *control_fp = NULL; diff --git a/citadel/domain.c b/citadel/domain.c index ccf62f7c7..69376cbb0 100644 --- a/citadel/domain.c +++ b/citadel/domain.c @@ -93,13 +93,15 @@ void sort_mxrecs(struct mx *mxrecs, int num_mxrecs) { * */ int getmx(char *mxbuf, char *dest) { - char answer[1024]; + union { + u_char bytes[1024]; + HEADER header; + } answer; int ret; unsigned char *startptr, *endptr, *ptr; char expanded_buf[1024]; unsigned short pref, type; int n = 0; - HEADER *hp; int qdcount; struct mx *mxrecs = NULL; @@ -116,7 +118,7 @@ int getmx(char *mxbuf, char *dest) { */ ret = res_query( dest, - C_IN, T_MX, (unsigned char *)answer, sizeof(answer) ); + C_IN, T_MX, (unsigned char *)answer.bytes, sizeof(answer) ); if (ret < 0) { mxrecs = mallok(sizeof(struct mx)); @@ -130,12 +132,11 @@ int getmx(char *mxbuf, char *dest) { if (ret > sizeof(answer)) ret = sizeof(answer); - hp = (HEADER *)&answer[0]; - startptr = &answer[0]; /* start and end of buffer */ - endptr = &answer[ret]; + startptr = &answer.bytes[0]; /* start and end of buffer */ + endptr = &answer.bytes[ret]; ptr = startptr + HFIXEDSZ; /* advance past header */ - for (qdcount = ntohs(hp->qdcount); qdcount--; ptr += ret + QFIXEDSZ) { + for (qdcount = ntohs(answer.header.qdcount); qdcount--; ptr += ret + QFIXEDSZ) { if ((ret = dn_skipname(ptr, endptr)) < 0) { lprintf(9, "dn_skipname error\n"); return(0); diff --git a/citadel/file_ops.c b/citadel/file_ops.c index a04dc32c9..61ad702d2 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -44,6 +44,9 @@ #include "tools.h" #include "citserver.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif /* * network_talking_to() -- concurrency checker diff --git a/citadel/imap_fetch.c b/citadel/imap_fetch.c index 0143a7b1f..2fc7ffe81 100644 --- a/citadel/imap_fetch.c +++ b/citadel/imap_fetch.c @@ -218,7 +218,7 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp, } fprintf(imfp->output_fp, "\r\n"); } - fprintf(imfp->output_fp, "Content-Length: %d\r\n", length); + fprintf(imfp->output_fp, "Content-Length: %ld\r\n", (long)length); fprintf(imfp->output_fp, "\r\n"); } diff --git a/citadel/imap_tools.c b/citadel/imap_tools.c index 58aabd897..c205dbd35 100644 --- a/citadel/imap_tools.c +++ b/citadel/imap_tools.c @@ -18,6 +18,10 @@ #include "imap_tools.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + /* * Output a string to the IMAP client, either as a literal or quoted. * (We do a literal if it has any double-quotes or backslashes.) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index ca0530d96..678189bb1 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -49,6 +49,11 @@ #include "parsedate.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + + struct trynamebuf { char buffer1[SIZ]; char buffer2[SIZ]; diff --git a/citadel/md5.c b/citadel/md5.c index 1488a1a4e..c0ba96afa 100644 --- a/citadel/md5.c +++ b/citadel/md5.c @@ -89,7 +89,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) } memcpy(p, buf, t); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); + MD5Transform(ctx->buf, ctx->in); buf += t; len -= t; } @@ -98,7 +98,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); + MD5Transform(ctx->buf, ctx->in); buf += 64; len -= 64; } @@ -122,7 +122,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ - p = ctx->in + count; + p = ((unsigned char*)ctx->in) + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ @@ -133,7 +133,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); + MD5Transform(ctx->buf, ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); @@ -336,7 +336,7 @@ void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16]) * md5 string */ -char *make_apop_string(char *realpass, char *nonce, u_char *buffer) +char *make_apop_string(char *realpass, char *nonce, char *buffer) { struct MD5Context ctx; u_char rawdigest[MD5_DIGEST_LEN]; @@ -344,9 +344,9 @@ char *make_apop_string(char *realpass, char *nonce, u_char *buffer) MD5Init(&ctx); // printf("MD5@@: Adding nonce: %s\n", nonce); - MD5Update(&ctx, nonce, strlen(nonce)); + MD5Update(&ctx, (u_char*)nonce, strlen(nonce)); // printf("MD5@@: Adding password %s\n", realpass); - MD5Update(&ctx, realpass, strlen(realpass)); + MD5Update(&ctx, (u_char*)realpass, strlen(realpass)); MD5Final(rawdigest, &ctx); for (i=0; icm_fields['T'] == NULL) { lprintf(9, "Generating timestamp\n"); - sprintf(aaa, "%ld", time(NULL)); + sprintf(aaa, "%ld", (long)time(NULL)); msg->cm_fields['T'] = strdoop(aaa); } @@ -1919,7 +1919,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n" "bounceto|%s@%s\n" "remote|%s|0||\n", - SPOOLMIME, newmsgid, time(NULL), + SPOOLMIME, newmsgid, (long)time(NULL), msg->cm_fields['A'], msg->cm_fields['N'], recipient ); @@ -2091,7 +2091,7 @@ static struct CtdlMessage *make_message( sprintf(buf, "cit%ld", author->usernum); /* Path */ msg->cm_fields['P'] = strdoop(buf); - sprintf(buf, "%ld", time(NULL)); /* timestamp */ + sprintf(buf, "%ld", (long)time(NULL)); /* timestamp */ msg->cm_fields['T'] = strdoop(buf); if (fake_name[0]) /* author */ @@ -2365,21 +2365,21 @@ void cmd_ent3(char *entargs) cprintf("%d %ld\n", SEND_BINARY, msglen); - client_read(&ch, 1); /* 0xFF magic number */ + client_read((char*)&ch, 1); /* 0xFF magic number */ msg->cm_magic = CTDLMESSAGE_MAGIC; - client_read(&ch, 1); /* anon type */ + client_read((char*)&ch, 1); /* anon type */ msg->cm_anon_type = ch; - client_read(&ch, 1); /* format type */ + client_read((char*)&ch, 1); /* format type */ msg->cm_format_type = ch; msglen = msglen - 3; while (msglen > 0) { - client_read(&which_field, 1); + client_read((char*)&which_field, 1); if (!isalpha(which_field)) valid_msg = 0; --msglen; tempbuf[0] = 0; do { - client_read(&ch, 1); + client_read((char*)&ch, 1); --msglen; a = strlen(tempbuf); tempbuf[a+1] = 0; diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index afe54a979..4ac4ce50f 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -43,6 +43,10 @@ #include "user_ops.h" #include "room_ops.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + struct ChatLine *ChatQueue = NULL; int ChatLastMsg = 0; diff --git a/citadel/serv_network.c b/citadel/serv_network.c index 2dd370bc3..37feb4079 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -56,6 +56,10 @@ #include "clientsocket.h" #include "file_ops.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + /* * When we do network processing, it's accomplished in two passes; one to @@ -167,7 +171,7 @@ int network_usetable(int operation, struct CtdlMessage *msg) { sprintf(&serialized_table[strlen( serialized_table)], "%s|%ld\n", ut->message_id, - ut->timestamp); + (long)ut->timestamp); } /* Now free the memory */ @@ -233,7 +237,7 @@ void write_network_map(void) { sprintf(&serialized_map[strlen(serialized_map)], "%s|%ld|%s\n", nmptr->nodename, - nmptr->lastcontact, + (long)nmptr->lastcontact, nmptr->nexthop); } } @@ -442,7 +446,7 @@ void network_spool_msg(long msgnum, void *userdata) { sprintf(instr, "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n" "bounceto|postmaster@%s\n" , - SPOOLMIME, msgnum, time(NULL), config.c_fqdn ); + SPOOLMIME, msgnum, (long)time(NULL), config.c_fqdn ); /* Generate delivery instructions for each recipient */ for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) { @@ -731,7 +735,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { phree(msg->cm_fields['I']); } sprintf(buf, "%ld.%04x.%04x@%s", - time(NULL), getpid(), ++serialnum, config.c_fqdn); + (long)time(NULL), getpid(), ++serialnum, config.c_fqdn); msg->cm_fields['I'] = strdoop(buf); /* diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index b79d44030..2d3ef0ceb 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -51,6 +51,10 @@ #include "clientsocket.h" +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + struct citsmtp { /* Information about the current session */ int command_state; char helo_node[SIZ]; diff --git a/citadel/snprintf.h b/citadel/snprintf.h index aa082b445..1a27cdf13 100644 --- a/citadel/snprintf.h +++ b/citadel/snprintf.h @@ -1,3 +1,5 @@ /* $Id$ */ +#ifndef __DECC int snprintf (char *buf, size_t max, const char *fmt, ...); int vsnprintf (char *buf, size_t max, const char *fmt, va_list argp); +#endif diff --git a/citadel/sysdep.c b/citadel/sysdep.c index f1c933f8e..86534cf07 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -123,7 +123,7 @@ void lprintf(int loglevel, const char *format, ...) { fprintf(stderr, "%04d/%02d/%02d %2d:%02d:%02d.%03ld %s", tim->tm_year + 1900, tim->tm_mon + 1, tim->tm_mday, tim->tm_hour, tim->tm_min, tim->tm_sec, - tv.tv_usec / 1000, buf); + (long)tv.tv_usec / 1000, buf); fflush(stderr); }