From 158b02e0e2e6c4693bdbba50009a329be3a05f77 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Wed, 10 Nov 2021 15:56:13 +0000 Subject: [PATCH] tidying --- src/exim_monitor/em_init.c | 81 ++++++++++++++++++-------------------- src/src/acl.c | 2 +- src/src/auths/gsasl_exim.c | 7 ++-- src/src/dns.c | 4 +- src/src/expand.c | 9 ++--- src/src/malware.c | 2 +- src/src/store.c | 10 ++++- src/src/tls-openssl.c | 3 -- src/src/transport.c | 2 +- src/src/transports/smtp.c | 8 ++-- src/src/verify.c | 3 +- 11 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/exim_monitor/em_init.c b/src/exim_monitor/em_init.c index e16897e95..e0bc3b066 100644 --- a/src/exim_monitor/em_init.c +++ b/src/exim_monitor/em_init.c @@ -115,38 +115,34 @@ void init(int argc, uschar **argv) int x; size_t erroroffset; uschar *s; -const uschar *error; argc = argc; /* These are currently unused. */ argv = argv; /* Deal with simple values in the environment. */ -s = US getenv("ACTION_OUTPUT"); -if (s != NULL) +if ((s = US getenv("ACTION_OUTPUT"))) { if (Ustrcmp(s, "no") == 0) action_output = FALSE; if (Ustrcmp(s, "yes") == 0) action_output = TRUE; } -s = US getenv("ACTION_QUEUE_UPDATE"); -if (s != NULL) +if ((s = US getenv("ACTION_QUEUE_UPDATE"))) { if (Ustrcmp(s, "no") == 0) action_queue_update = FALSE; if (Ustrcmp(s, "yes") == 0) action_queue_update = TRUE; } s = US getenv("BODY_MAX"); -if (s != NULL && (x = Uatoi(s)) != 0) body_max = x; +if (s && (x = Uatoi(s)) != 0) body_max = x; -s = US getenv("EXIM_PATH"); -if (s != NULL) exim_path = string_copy(s); +if ((s = US getenv("EXIM_PATH"))) + exim_path = string_copy(s); -s = US getenv("EXIMON_EXIM_CONFIG"); -if (s != NULL) alternate_config = string_copy(s); +if ((s = US getenv("EXIMON_EXIM_CONFIG"))) + alternate_config = string_copy(s); -s = US getenv("LOG_BUFFER"); -if (s != NULL) +if ((s = US getenv("LOG_BUFFER"))) { uschar c[1]; if (sscanf(CS s, "%d%c", &x, c) > 0) @@ -158,63 +154,64 @@ if (s != NULL) } s = US getenv("LOG_DEPTH"); -if (s != NULL && (x = Uatoi(s)) != 0) log_depth = x; +if (s && (x = Uatoi(s)) != 0) log_depth = x; -s = US getenv("LOG_FILE_NAME"); -if (s != NULL) log_file = string_copy(s); +if ((s = US getenv("LOG_FILE_NAME"))) + log_file = string_copy(s); -s = US getenv("LOG_FONT"); -if (s != NULL) log_font = string_copy(s); +if ((s = US getenv("LOG_FONT"))) + log_font = string_copy(s); s = US getenv("LOG_WIDTH"); -if (s != NULL && (x = Uatoi(s)) != 0) log_width = x; +if (s && (x = Uatoi(s)) != 0) log_width = x; -s = US getenv("MENU_EVENT"); -if (s != NULL) menu_event = string_copy(s); +if ((s = US getenv("MENU_EVENT"))) + menu_event = string_copy(s); s = US getenv("MIN_HEIGHT"); -if (s != NULL && (x = Uatoi(s)) > 0) min_height = x; +if (s && (x = Uatoi(s)) > 0) min_height = x; s = US getenv("MIN_WIDTH"); -if (s != NULL && (x = Uatoi(s)) > 0) min_width = x; +if (s && (x = Uatoi(s)) > 0) min_width = x; -s = US getenv("QUALIFY_DOMAIN"); -if (s != NULL) qualify_domain = string_copy(s); - else qualify_domain = US""; /* Don't want NULL */ +if ((s = US getenv("QUALIFY_DOMAIN"))) + qualify_domain = string_copy(s); +else + qualify_domain = US""; /* Don't want NULL */ s = US getenv("QUEUE_DEPTH"); -if (s != NULL && (x = Uatoi(s)) != 0) queue_depth = x; +if (s && (x = Uatoi(s)) != 0) queue_depth = x; -s = US getenv("QUEUE_FONT"); -if (s != NULL) queue_font = string_copy(s); +if ((s = US getenv("QUEUE_FONT"))) + queue_font = string_copy(s); s = US getenv("QUEUE_INTERVAL"); -if (s != NULL && (x = Uatoi(s)) != 0) queue_update = x; +if (s && (x = Uatoi(s)) != 0) queue_update = x; s = US getenv("QUEUE_MAX_ADDRESSES"); -if (s != NULL && (x = Uatoi(s)) != 0) queue_max_addresses = x; +if (s && (x = Uatoi(s)) != 0) queue_max_addresses = x; s = US getenv("QUEUE_WIDTH"); -if (s != NULL && (x = Uatoi(s)) != 0) queue_width = x; +if (s && (x = Uatoi(s)) != 0) queue_width = x; -s = US getenv("SPOOL_DIRECTORY"); -if (s != NULL) spool_directory = string_copy(s); +if ((s = US getenv("SPOOL_DIRECTORY"))) + spool_directory = string_copy(s); s = US getenv("START_SMALL"); -if (s != NULL && Ustrcmp(s, "yes") == 0) start_small = 1; +if (s && Ustrcmp(s, "yes") == 0) start_small = 1; s = US getenv("TEXT_DEPTH"); -if (s != NULL && (x = Uatoi(s)) != 0) text_depth = x; +if (s && (x = Uatoi(s)) != 0) text_depth = x; -s = US getenv("WINDOW_TITLE"); -if (s != NULL) window_title = string_copy(s); +if ((s = US getenv("WINDOW_TITLE"))) + window_title = string_copy(s); /* Deal with stripchart configuration. First see if we are monitoring the size of a partition, then deal with log stripcharts in a separate function */ s = US getenv("SIZE_STRIPCHART"); -if (s != NULL && *s != 0) +if (s && *s) { stripchart_number++; stripchart_varstart++; @@ -223,14 +220,14 @@ if (s != NULL && *s != 0) if (s != NULL && *s != 0) size_stripchart_name = string_copy(s); } -s = US getenv("LOG_STRIPCHARTS"); -if (s != NULL) decode_stripchart_config(s); +if ((s = US getenv("LOG_STRIPCHARTS"))) + decode_stripchart_config(s); s = US getenv("STRIPCHART_INTERVAL"); -if (s != NULL && (x = Uatoi(s)) != 0) stripchart_update = x; +if (s && (x = Uatoi(s)) != 0) stripchart_update = x; s = US getenv("QUEUE_STRIPCHART_NAME"); -queue_stripchart_name = (s != NULL)? string_copy(s) : US"queue"; +queue_stripchart_name = s ? string_copy(s) : US"queue"; /* Compile the regex for matching yyyy-mm-dd at the start of a string. */ diff --git a/src/src/acl.c b/src/src/acl.c index 15023c7cc..5252292ff 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -2884,7 +2884,7 @@ acl_seen(const uschar * arg, int where, uschar ** log_msgptr) enum { SEEN_DEFAULT, SEEN_READONLY, SEEN_WRITE }; const uschar * list = arg; -int slash = '/', equal = '=', interval, mode = SEEN_DEFAULT, yield = FAIL; +int slash = '/', interval, mode = SEEN_DEFAULT, yield = FAIL; BOOL before; int refresh = 10 * 24 * 60 * 60; /* 10 days */ const uschar * ele, * key = sender_host_address; diff --git a/src/src/auths/gsasl_exim.c b/src/src/auths/gsasl_exim.c index 2d060d4da..26505446a 100644 --- a/src/src/auths/gsasl_exim.c +++ b/src/src/auths/gsasl_exim.c @@ -642,10 +642,10 @@ static int server_callback(Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop, auth_instance *ablock) { -char *tmps; -uschar *s, *propval; +char * tmps; +uschar * s; int cbrc = GSASL_NO_CALLBACK; -auth_gsasl_options_block *ob = +auth_gsasl_options_block * ob = (auth_gsasl_options_block *)(ablock->options_block); HDEBUG(D_auth) debug_printf("GNU SASL callback %s for %s/%s as server\n", @@ -786,7 +786,6 @@ set_client_prop(Gsasl_session * sctx, Gsasl_property prop, uschar * val, unsigned flags, uschar * buffer, int buffsize) { uschar * s; -int rc; if (!val) return !!(flags & PROP_OPTIONAL); if (!(s = expand_string(val)) || !(flags & PROP_OPTIONAL) && !*s) diff --git a/src/src/dns.c b/src/src/dns.c index 8bf7f6542..07c51e2dc 100644 --- a/src/src/dns.c +++ b/src/src/dns.c @@ -1148,7 +1148,7 @@ switch (type) case T_CSA: { uschar *srvname, *namesuff, *tld; - int priority, weight, port; + int priority, dummy_weight, port; int limit, rc, i; BOOL ipv6; dns_record *rr; @@ -1237,7 +1237,7 @@ switch (type) /* Extract the numerical SRV fields (p is incremented) */ GETSHORT(priority, p); - GETSHORT(weight, p); + GETSHORT(dummy_weight, p); GETSHORT(port, p); /* Check the CSA version number */ diff --git a/src/src/expand.c b/src/src/expand.c index 53ad3ff92..59554840e 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -4319,7 +4319,6 @@ tree_node *t = NULL; const uschar * list; int sep = 0; uschar * item; -uschar * suffix = US""; BOOL needsep = FALSE; #define LISTNAMED_BUF_SIZE 256 uschar b[LISTNAMED_BUF_SIZE]; @@ -4335,10 +4334,10 @@ if (!listtype) /* no-argument version */ } else switch(*listtype) /* specific list-type version */ { - case 'a': t = tree_search(addresslist_anchor, name); suffix = US"_a"; break; - case 'd': t = tree_search(domainlist_anchor, name); suffix = US"_d"; break; - case 'h': t = tree_search(hostlist_anchor, name); suffix = US"_h"; break; - case 'l': t = tree_search(localpartlist_anchor, name); suffix = US"_l"; break; + case 'a': t = tree_search(addresslist_anchor, name); break; + case 'd': t = tree_search(domainlist_anchor, name); break; + case 'h': t = tree_search(hostlist_anchor, name); break; + case 'l': t = tree_search(localpartlist_anchor, name); break; default: expand_string_message = US"bad suffix on \"list\" operator"; return yield; diff --git a/src/src/malware.c b/src/src/malware.c index 1dc89ae15..10a390dfa 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1457,7 +1457,7 @@ badseek: err = errno; uschar av_buffer[1024]; uschar *hostname = US""; host_item connhost; - int clam_fd, result; + int clam_fd; unsigned int fsize_uint; BOOL use_scan_command = FALSE; clamd_address * cv[MAX_CLAMD_SERVERS]; diff --git a/src/src/store.c b/src/src/store.c index 520305dbb..e4cd722c3 100644 --- a/src/src/store.c +++ b/src/src/store.c @@ -283,7 +283,7 @@ Returns: pointer to store (panic on malloc failure) */ void * -store_get_3(int size, BOOL tainted, const char *func, int linenumber) +store_get_3(int size, BOOL tainted, const char * func, int linenumber) { int pool = tainted ? store_pool + POOL_TAINT_BASE : store_pool; @@ -347,7 +347,13 @@ if (size > yield_length[pool]) if (pool == POOL_CONFIG) { long pgsize = sysconf(_SC_PAGESIZE); - posix_memalign((void **)&newblock, pgsize, (mlength + pgsize - 1) & ~(pgsize - 1)); + int err = posix_memalign((void **)&newblock, + pgsize, (mlength + pgsize - 1) & ~(pgsize - 1)); + if (err) + log_write(0, LOG_MAIN|LOG_PANIC_DIE, + "failed to alloc (using posix_memalign) %d bytes of memory: '%s'" + "called from line %d in %s", + size, strerror(err), linenumber, func); } else #endif diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index e8d14398f..51eeedc5b 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -2235,9 +2235,6 @@ if (!olist) const X509 * cert_sent = SSL_get_certificate(s); const ASN1_INTEGER * cert_serial = X509_get0_serialNumber(cert_sent); const BIGNUM * cert_bn = ASN1_INTEGER_to_BN(cert_serial, NULL); - const X509_NAME * cert_issuer = X509_get_issuer_name(cert_sent); - uschar * chash; - uint chash_len; for (; olist; olist = olist->next) { diff --git a/src/src/transport.c b/src/src/transport.c index 0c2c6e29a..8c74030f0 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -1398,7 +1398,7 @@ if (write_pid > 0) yield = FALSE; } else if (!ok) - { + { /* Try to drain the pipe; read fails are don't care */ int dummy = read(pfd[pipe_read], (void *)&save_errno, sizeof(int)); dummy = read(pfd[pipe_read], (void *)&tctx->addr->more_errno, sizeof(int)); dummy = read(pfd[pipe_read], (void *)&tctx->addr->delivery_time, sizeof(struct timeval)); diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 6f4e7ab71..d321bd69e 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -716,9 +716,11 @@ BOOL good_response; { /* Hack to get QUICKACK disabled; has to be right after 3whs, and has to on->off */ int sock = sx->cctx.sock; struct pollfd p = {.fd = sock, .events = POLLOUT}; - int rc = poll(&p, 1, 1000); - (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &on, sizeof(on)); - (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &off, sizeof(off)); + if (poll(&p, 1, 1000) >= 0) /* retval test solely for compiler quitening */ + { + (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &on, sizeof(on)); + (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &off, sizeof(off)); + } } #endif good_response = smtp_read_response(sx, sx->buffer, sizeof(sx->buffer), diff --git a/src/src/verify.c b/src/src/verify.c index 0ac6a7c74..c182e12e1 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -3577,9 +3577,10 @@ else close(pfd[pipe_read]); errno = save_errno; +return yield; fail: - +DEBUG(D_verify) debug_printf_indent("verify_quota_call fail in %s\n", where); return yield; } -- 2.30.2