From: Phil Pennock Date: Mon, 7 Jun 2010 00:12:42 +0000 (+0000) Subject: Clean up compiler warnings from { gcc -Wall }, many of which I introduced with X-Git-Tag: exim-4_73_RC0~43 X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/73a4670220991e000cc31a60fc90264cf12bd981 Clean up compiler warnings from { gcc -Wall }, many of which I introduced with the ClamAV and openssl_options patches in this release. Logic in buildconfig.c for adjusting some print format strings assumed that long ints were four bytes; adjust to test this against reality, to remove spurious warnings on my dev box (FreeBSD/amd64). Note: this commit adds a buildconfig.h dependency upon inttypes.h, which was in SUSv2, so should be safe. --- diff --git a/src/src/buildconfig.c b/src/src/buildconfig.c index 36561a968..b53869cf1 100644 --- a/src/src/buildconfig.c +++ b/src/src/buildconfig.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/buildconfig.c,v 1.16 2010/06/06 02:46:13 pdp Exp $ */ +/* $Cambridge: exim/src/src/buildconfig.c,v 1.17 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -34,6 +34,7 @@ normally called independently. */ #include +#include #include #include #include @@ -103,6 +104,9 @@ main(int argc, char **argv) { off_t test_off_t = 0; time_t test_time_t = 0; +size_t test_size_t = 0; +unsigned long test_ulong_t = 0L; +long test_long_t = 0; FILE *base; FILE *new; int last_initial = 'A'; @@ -145,7 +149,7 @@ printing long long variables, and there will be support for the long long type. This assumption is known to be OK for the common operating systems. */ fprintf(new, "#ifndef OFF_T_FMT\n"); -if (sizeof(test_off_t) > 4) +if (sizeof(test_off_t) > sizeof(test_long_t)) { fprintf(new, "#define OFF_T_FMT \"%%lld\"\n"); fprintf(new, "#define LONGLONG_T long long int\n"); @@ -163,7 +167,7 @@ length is 4 or less, we can leave LONGLONG_T to whatever was defined above for off_t. */ fprintf(new, "#ifndef TIME_T_FMT\n"); -if (sizeof(test_time_t) > 4) +if (sizeof(test_time_t) > sizeof(test_long_t)) { fprintf(new, "#define TIME_T_FMT \"%%lld\"\n"); fprintf(new, "#undef LONGLONG_T\n"); @@ -175,6 +179,23 @@ else } fprintf(new, "#endif\n\n"); +/* And for sizeof() results, size_t, which should with C99 be just %zu, deal +with C99 not being ubiquitous yet. Unfortunately. */ + +#if __STDC_VERSION__ >= 199901L +fprintf(new, "#define SIZE_T_FMT \"%%zu\"\n"); +#else +/*# ifdef PRIdMAX */ +#if 0 +fprintf(new, "#define SIZE_T_FMT \"%%" PRIdMAX "\"\n"); +# else +if (sizeof(test_size_t) > sizeof (test_ulong_t)) + fprintf(new, "#define SIZE_T_FMT \"%%llu\"\n"); +else + fprintf(new, "#define SIZE_T_FMT \"%%lu\"\n"); +# endif +#endif + /* Now search the makefile for certain settings */ base = fopen("Makefile", "rb"); diff --git a/src/src/exim.c b/src/src/exim.c index 890bcebe9..50950faa5 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.70 2010/06/06 22:46:34 pdp Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.71 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -905,7 +905,7 @@ if (fixed_never_users[0] > 0) fprintf(f, "%d\n", (unsigned int)fixed_never_users[i]); } -fprintf(f, "Size of off_t: %d\n", sizeof(off_t)); +fprintf(f, "Size of off_t: " SIZE_T_FMT "\n", sizeof(off_t)); /* This runtime check is to help diagnose library linkage mismatches which result in segfaults and the like; as such, it's left until the end, @@ -1570,7 +1570,7 @@ for (i = 1; i < argc; i++) else if (Ustrcmp(argrest, "version") == 0) { switchchar = 'b'; - argrest = "V"; + argrest = US"V"; } } diff --git a/src/src/malware.c b/src/src/malware.c index 61b0c2994..f82bef63e 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/malware.c,v 1.20 2010/06/06 22:46:34 pdp Exp $ */ +/* $Cambridge: exim/src/src/malware.c,v 1.21 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -106,23 +106,23 @@ malware_in_file(uschar *eml_filename) { uschar message_id_buf[64]; int ret; - scan_options[0] = "*"; + scan_options[0] = US"*"; scan_options[1] = NULL; /* spool_mbox() assumes various parameters exist, when creating the relevant directory and the email within */ (void) string_format(message_id_buf, sizeof(message_id_buf), - US"dummy-%d", pseudo_random_number(INT_MAX)); + "dummy-%d", pseudo_random_number(INT_MAX)); message_id = message_id_buf; - sender_address = "malware-sender@example.net"; - return_path = ""; + sender_address = US"malware-sender@example.net"; + return_path = US""; recipients_list = NULL; - receive_add_recipient("malware-victim@example.net", -1); + receive_add_recipient(US"malware-victim@example.net", -1); enable_dollar_recipients = TRUE; ret = malware_internal(scan_options, eml_filename, TRUE); - strncpy(spooled_message_id, message_id, sizeof(spooled_message_id)); + Ustrncpy(spooled_message_id, message_id, sizeof(spooled_message_id)); spool_mbox_ok = 1; /* don't set no_mbox_unspool; at present, there's no way for it to become set, but if that changes, then it should apply to these tests too */ @@ -891,7 +891,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) log_write(0, LOG_MAIN|LOG_PANIC, "malware filename does not fit in buffer [malware_internal() kavdaemon]"); } - p = strrchr(scanrequest, '/'); + p = Ustrrchr(scanrequest, '/'); if (p) *p = '\0'; @@ -1098,7 +1098,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) "malware filename does not fit in buffer [malware_internal() cmdline]"); return DEFER; } - p = strrchr(eml_filename, '/'); + p = Ustrrchr(eml_filename, '/'); if (p) *p = '\0'; fits = string_format(commandline, sizeof(commandline), CS cmdline_scanner, file_name); @@ -1199,7 +1199,6 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) struct sockaddr_un server; int sock, len; uschar *p; - BOOL fits; uschar file_name[1024]; uschar av_buffer[1024]; @@ -1236,7 +1235,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) return DEFER; } memcpy(file_name, eml_filename, len); - p = strrchr(file_name, '/'); + p = Ustrrchr(file_name, '/'); if (p) *p = '\0'; @@ -1311,12 +1310,12 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) uschar clamd_options2_buffer[1024]; uschar clamd_options2_default[] = ""; uschar *clamav_fbuf; - uschar scanrequest[1024]; - int sockData, clam_fd, result; + int clam_fd, result; unsigned int fsize; BOOL use_scan_command, fits; #ifdef WITH_OLD_CLAMAV_STREAM uschar av_buffer2[1024]; + int sockData; #else uint32_t send_size, send_final_zeroblock; #endif diff --git a/src/src/readconf.c b/src/src/readconf.c index adb62205d..fbba20690 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/readconf.c,v 1.40 2010/06/05 09:10:10 pdp Exp $ */ +/* $Cambridge: exim/src/src/readconf.c,v 1.41 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2751,7 +2751,6 @@ void readconf_main(void) { int sep = 0; -long dummy_l; struct stat statbuf; uschar *s, *filename; uschar *list = config_main_filelist; diff --git a/src/src/rfc2047.c b/src/src/rfc2047.c index aec4a536e..553b0e618 100644 --- a/src/src/rfc2047.c +++ b/src/src/rfc2047.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/rfc2047.c,v 1.5 2009/11/16 19:50:37 nm4 Exp $ */ +/* $Cambridge: exim/src/src/rfc2047.c,v 1.6 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -279,7 +279,7 @@ while (mimeword != NULL) else { DEBUG(D_any) debug_printf("iconv error translating \"%.*s\" to %s: " - "%s\n", endword + 2 - mimeword, mimeword, target, strerror(errno)); + "%s\n", (int)(endword + 2 - mimeword), mimeword, target, strerror(errno)); } } diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index 78b28f5e8..e01edc008 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/tls-openssl.c,v 1.26 2010/06/05 10:34:29 pdp Exp $ */ +/* $Cambridge: exim/src/src/tls-openssl.c,v 1.27 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -360,7 +360,7 @@ availability of the option value macros from OpenSSL. */ okay = tls_openssl_options_parse(openssl_options, &init_options); if (!okay) - return tls_error("openssl_options parsing failed", host, NULL); + return tls_error(US"openssl_options parsing failed", host, NULL); if (init_options) { @@ -1179,61 +1179,61 @@ This list is current as of: static struct exim_openssl_option exim_openssl_options[] = { /* KEEP SORTED ALPHABETICALLY! */ #ifdef SSL_OP_ALL - { "all", SSL_OP_ALL }, + { US"all", SSL_OP_ALL }, #endif #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION - { "allow_unsafe_legacy_renegotiation", SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION }, + { US"allow_unsafe_legacy_renegotiation", SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION }, #endif #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE - { "cipher_server_preference", SSL_OP_CIPHER_SERVER_PREFERENCE }, + { US"cipher_server_preference", SSL_OP_CIPHER_SERVER_PREFERENCE }, #endif #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS - { "dont_insert_empty_fragments", SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS }, + { US"dont_insert_empty_fragments", SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS }, #endif #ifdef SSL_OP_EPHEMERAL_RSA - { "ephemeral_rsa", SSL_OP_EPHEMERAL_RSA }, + { US"ephemeral_rsa", SSL_OP_EPHEMERAL_RSA }, #endif #ifdef SSL_OP_LEGACY_SERVER_CONNECT - { "legacy_server_connect", SSL_OP_LEGACY_SERVER_CONNECT }, + { US"legacy_server_connect", SSL_OP_LEGACY_SERVER_CONNECT }, #endif #ifdef SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER - { "microsoft_big_sslv3_buffer", SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER }, + { US"microsoft_big_sslv3_buffer", SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER }, #endif #ifdef SSL_OP_MICROSOFT_SESS_ID_BUG - { "microsoft_sess_id_bug", SSL_OP_MICROSOFT_SESS_ID_BUG }, + { US"microsoft_sess_id_bug", SSL_OP_MICROSOFT_SESS_ID_BUG }, #endif #ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING - { "msie_sslv2_rsa_padding", SSL_OP_MSIE_SSLV2_RSA_PADDING }, + { US"msie_sslv2_rsa_padding", SSL_OP_MSIE_SSLV2_RSA_PADDING }, #endif #ifdef SSL_OP_NETSCAPE_CHALLENGE_BUG - { "netscape_challenge_bug", SSL_OP_NETSCAPE_CHALLENGE_BUG }, + { US"netscape_challenge_bug", SSL_OP_NETSCAPE_CHALLENGE_BUG }, #endif #ifdef SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG - { "netscape_reuse_cipher_change_bug", SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG }, + { US"netscape_reuse_cipher_change_bug", SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG }, #endif #ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION - { "no_session_resumption_on_renegotiation", SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION }, + { US"no_session_resumption_on_renegotiation", SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION }, #endif #ifdef SSL_OP_SINGLE_DH_USE - { "single_dh_use", SSL_OP_SINGLE_DH_USE }, + { US"single_dh_use", SSL_OP_SINGLE_DH_USE }, #endif #ifdef SSL_OP_SINGLE_ECDH_USE - { "single_ecdh_use", SSL_OP_SINGLE_ECDH_USE }, + { US"single_ecdh_use", SSL_OP_SINGLE_ECDH_USE }, #endif #ifdef SSL_OP_SSLEAY_080_CLIENT_DH_BUG - { "ssleay_080_client_dh_bug", SSL_OP_SSLEAY_080_CLIENT_DH_BUG }, + { US"ssleay_080_client_dh_bug", SSL_OP_SSLEAY_080_CLIENT_DH_BUG }, #endif #ifdef SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG - { "sslref2_reuse_cert_type_bug", SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG }, + { US"sslref2_reuse_cert_type_bug", SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG }, #endif #ifdef SSL_OP_TLS_BLOCK_PADDING_BUG - { "tls_block_padding_bug", SSL_OP_TLS_BLOCK_PADDING_BUG }, + { US"tls_block_padding_bug", SSL_OP_TLS_BLOCK_PADDING_BUG }, #endif #ifdef SSL_OP_TLS_D5_BUG - { "tls_d5_bug", SSL_OP_TLS_D5_BUG }, + { US"tls_d5_bug", SSL_OP_TLS_D5_BUG }, #endif #ifdef SSL_OP_TLS_ROLLBACK_BUG - { "tls_rollback_bug", SSL_OP_TLS_ROLLBACK_BUG }, + { US"tls_rollback_bug", SSL_OP_TLS_ROLLBACK_BUG }, #endif }; static int exim_openssl_options_size = diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index 780e4b245..e53761582 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.26 2010/05/29 12:11:48 pdp Exp $ */ +/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.27 2010/06/07 00:12:42 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2073,7 +2073,7 @@ if (!isdirectory) goto RETURN; } - if (lstat(mbx_lockname, &lstatbuf) < 0) + if (Ulstat(mbx_lockname, &lstatbuf) < 0) { addr->basic_errno = ERRNO_LOCKFAILED; addr->message = string_sprintf("attempting to lstat open MBX "