From 2d0dc9298e36bb9c010ede2c42db16e3ab00da79 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 17 Feb 2018 16:43:44 +0000 Subject: [PATCH] tidying --- src/src/exim.c | 2 +- src/src/expand.c | 6 +- src/src/host.c | 6 +- src/src/routers/rf_self_action.c | 96 +++++++++++++------------------- src/src/smtp_in.c | 14 ++--- src/src/verify.c | 54 ++++++++---------- 6 files changed, 75 insertions(+), 103 deletions(-) diff --git a/src/src/exim.c b/src/src/exim.c index f95c10747..870b33949 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -5208,7 +5208,7 @@ already been done (which it will have been for inetd). This caters for the case when it is forced by -oMa. However, we must flag that it isn't a socket, so that the test for IP options is skipped for -bs input. */ -if (sender_host_address != NULL && sender_fullhost == NULL) +if (sender_host_address && !sender_fullhost) { host_build_sender_fullhost(); set_process_info("handling incoming connection from %s via -oMa", diff --git a/src/src/expand.c b/src/src/expand.c index de38e3acb..c7ebf9870 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1797,10 +1797,10 @@ switch (vp->type) return var_buffer; case vtype_host_lookup: /* Lookup if not done so */ - if (sender_host_name == NULL && sender_host_address != NULL && - !host_lookup_failed && host_name_lookup() == OK) + if ( !sender_host_name && sender_host_address + && !host_lookup_failed && host_name_lookup() == OK) host_build_sender_fullhost(); - return (sender_host_name == NULL)? US"" : sender_host_name; + return sender_host_name ? sender_host_name : US""; case vtype_localpart: /* Get local part from address */ s = *((uschar **)(val)); diff --git a/src/src/host.c b/src/src/host.c index daa737954..fbc46575d 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -534,7 +534,7 @@ uschar *address; int len; int old_pool = store_pool; -if (sender_host_address == NULL) return; +if (!sender_host_address) return; store_pool = POOL_PERM; @@ -549,7 +549,7 @@ if (!LOGGING(incoming_port) || sender_host_port <= 0) /* If there's no EHLO/HELO data, we can't show it. */ -if (sender_helo_name == NULL) show_helo = FALSE; +if (!sender_helo_name) show_helo = FALSE; /* If HELO/EHLO was followed by an IP literal, it's messy because of two features of IPv6. Firstly, there's the "IPv6:" prefix (Exim is liberal and @@ -599,7 +599,7 @@ if (!sender_host_name) g = string_catn(NULL, address, adlen); - if (sender_ident != NULL || show_helo || portptr != NULL) + if (sender_ident || show_helo || portptr) { int firstptr; g = string_catn(g, US" (", 2); diff --git a/src/src/routers/rf_self_action.c b/src/src/routers/rf_self_action.c index 7434ddd07..9a4dc3cc7 100644 --- a/src/src/routers/rf_self_action.c +++ b/src/src/routers/rf_self_action.c @@ -60,79 +60,61 @@ int rf_self_action(address_item *addr, host_item *host, int code, BOOL rewrite, uschar *new, address_item **addr_new) { -uschar *msg = (host->mx >= 0)? - US"lowest numbered MX record points to local host" : - US"remote host address is the local host"; +uschar * msg = host->mx >= 0 + ? US"lowest numbered MX record points to local host" + : US"remote host address is the local host"; switch (code) { case self_freeze: - /* If there is no message id, this is happening during an address - verification, so give information about the address that is being verified, - and where it has come from. Otherwise, during message delivery, the normal - logging for the address will be sufficient. */ - - if (message_id[0] == 0) - { - if (sender_fullhost == NULL) - { - log_write(0, LOG_MAIN, "%s: %s (while routing <%s>)", msg, - addr->domain, addr->address); - } + /* If there is no message id, this is happening during an address + verification, so give information about the address that is being verified, + and where it has come from. Otherwise, during message delivery, the normal + logging for the address will be sufficient. */ + + if (message_id[0] == 0) + if (sender_fullhost) + log_write(0, LOG_MAIN, "%s: %s (while verifying <%s> from host %s)", + msg, addr->domain, addr->address, sender_fullhost); + else + log_write(0, LOG_MAIN, "%s: %s (while routing <%s>)", msg, + addr->domain, addr->address); else - { - log_write(0, LOG_MAIN, "%s: %s (while verifying <%s> from host %s)", - msg, addr->domain, addr->address, sender_fullhost); - } - } - else - log_write(0, LOG_MAIN, "%s: %s", msg, addr->domain); - - addr->message = msg; - addr->special_action = SPECIAL_FREEZE; - return DEFER; + log_write(0, LOG_MAIN, "%s: %s", msg, addr->domain); + + addr->message = msg; + addr->special_action = SPECIAL_FREEZE; + return DEFER; case self_defer: - addr->message = msg; - return DEFER; + addr->message = msg; + return DEFER; case self_reroute: - DEBUG(D_route) - { - debug_printf("%s: %s", msg, addr->domain); - debug_printf(": domain changed to %s\n", new); - } - rf_change_domain(addr, new, rewrite, addr_new); - return REROUTED; + DEBUG(D_route) + debug_printf("%s: %s: domain changed to %s\n", msg, addr->domain, new); + rf_change_domain(addr, new, rewrite, addr_new); + return REROUTED; case self_send: - DEBUG(D_route) - { - debug_printf("%s: %s", msg, addr->domain); - debug_printf(": configured to try delivery anyway\n"); - } - return OK; + DEBUG(D_route) + debug_printf("%s: %s: configured to try delivery anyway\n", msg, addr->domain); + return OK; case self_pass: /* This is soft failure; pass to next router */ - DEBUG(D_route) - { - debug_printf("%s: %s", msg, addr->domain); - debug_printf(": passed to next router (self = pass)\n"); - } - addr->message = msg; - addr->self_hostname = string_copy(host->name); - return PASS; + DEBUG(D_route) + debug_printf("%s: %s: passed to next router (self = pass)\n", msg, addr->domain); + addr->message = msg; + addr->self_hostname = string_copy(host->name); + return PASS; case self_fail: - DEBUG(D_route) - { - debug_printf("%s: %s", msg, addr->domain); - debug_printf(": address failed (self = fail)\n"); - } - addr->message = msg; - setflag(addr, af_pass_message); - return FAIL; + DEBUG(D_route) + debug_printf("%s: %s: address failed (self = fail)\n", msg, addr->domain); + addr->message = msg; + setflag(addr, af_pass_message); + return FAIL; } return DEFER; /* paranoia */ diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 929a8037a..dea776dcc 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1838,7 +1838,7 @@ BOOL yield = helo_accept_junk; /* Discard any previous helo name */ -if (sender_helo_name != NULL) +if (sender_helo_name) { store_free(sender_helo_name); sender_helo_name = NULL; @@ -4040,9 +4040,9 @@ while (done <= 0) /* Force a reverse lookup if HELO quoted something in helo_lookup_domains because otherwise the log can be confusing. */ - if (sender_host_name == NULL && - (deliver_domain = sender_helo_name, /* set $domain */ - match_isinlist(sender_helo_name, CUSS &helo_lookup_domains, 0, + if ( !sender_host_name + && (deliver_domain = sender_helo_name, /* set $domain */ + match_isinlist(sender_helo_name, CUSS &helo_lookup_domains, 0, &domainlist_anchor, NULL, MCL_DOMAIN, TRUE, NULL)) == OK) (void)host_name_lookup(); @@ -5336,7 +5336,7 @@ while (done <= 0) cmd_list[CMD_LIST_EHLO].is_mail_cmd = TRUE; cmd_list[CMD_LIST_AUTH].is_mail_cmd = TRUE; cmd_list[CMD_LIST_TLS_AUTH].is_mail_cmd = TRUE; - if (sender_helo_name != NULL) + if (sender_helo_name) { store_free(sender_helo_name); sender_helo_name = NULL; @@ -5497,7 +5497,7 @@ while (done <= 0) case ETRN_CMD: HAD(SCH_ETRN); - if (sender_address != NULL) + if (sender_address) { done = synprot_error(L_smtp_protocol_error, 503, NULL, US"ETRN is not permitted inside a transaction"); @@ -5523,7 +5523,7 @@ while (done <= 0) since that is strictly the only kind of ETRN that can be implemented according to the RFC. */ - if (smtp_etrn_command != NULL) + if (smtp_etrn_command) { uschar *error; BOOL rc; diff --git a/src/src/verify.c b/src/src/verify.c index 08a3576fc..0d8c97097 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -3076,7 +3076,7 @@ if (isquery) /* Not a query-style lookup; must ensure the host name is present, and then we do a check on the name and all its aliases. */ -if (sender_host_name == NULL) +if (!sender_host_name) { HDEBUG(D_host_lookup) debug_printf("sender host name required, to match against %s\n", ss); @@ -3091,8 +3091,7 @@ if (sender_host_name == NULL) /* Match on the sender host name, using the general matching function */ -switch(match_check_string(sender_host_name, ss, -1, TRUE, TRUE, TRUE, - valueptr)) +switch(match_check_string(sender_host_name, ss, -1, TRUE, TRUE, TRUE, valueptr)) { case OK: return OK; case DEFER: return DEFER; @@ -3101,14 +3100,12 @@ switch(match_check_string(sender_host_name, ss, -1, TRUE, TRUE, TRUE, /* If there are aliases, try matching on them. */ aliases = sender_host_aliases; -while (*aliases != NULL) - { +while (*aliases) switch(match_check_string(*aliases++, ss, -1, TRUE, TRUE, TRUE, valueptr)) { case OK: return OK; case DEFER: return DEFER; } - } return FAIL; } @@ -3407,25 +3404,23 @@ else for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); rr; rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT)) - { if (rr->type == T_A) { dns_address *da = dns_address_from_rr(&dnsa, rr); if (da) { *addrp = da; - while (da->next != NULL) da = da->next; - addrp = &(da->next); + while (da->next) da = da->next; + addrp = &da->next; if (ttl > rr->ttl) ttl = rr->ttl; } } - } /* If we didn't find any A records, change the return code. This can happen when there is a CNAME record but there are no A records for what it points to. */ - if (cb->rhs == NULL) cb->rc = DNS_NODATA; + if (!cb->rhs) cb->rc = DNS_NODATA; } cb->expiry = time(NULL)+ttl; @@ -3447,7 +3442,7 @@ if (cb->rc == DNS_SUCCEED) records. For A6 records (currently not expected to be used) there may be multiple addresses from a single record. */ - for (da = cb->rhs->next; da != NULL; da = da->next) + for (da = cb->rhs->next; da; da = da->next) addlist = string_sprintf("%s, %s", addlist, da->address); HDEBUG(D_dnsbl) debug_printf("DNS lookup for %s succeeded (yielding %s)\n", @@ -3456,9 +3451,9 @@ if (cb->rc == DNS_SUCCEED) /* Address list check; this can be either for equality, or via a bitmask. In the latter case, all the bits must match. */ - if (iplist != NULL) + if (iplist) { - for (da = cb->rhs; da != NULL; da = da->next) + for (da = cb->rhs; da; da = da->next) { int ipsep = ','; uschar ip[46]; @@ -3468,12 +3463,11 @@ if (cb->rc == DNS_SUCCEED) /* Handle exact matching */ if (!bitmask) - { - while ((res = string_nextinlist(&ptr, &ipsep, ip, sizeof(ip))) != NULL) - { - if (Ustrcmp(CS da->address, ip) == 0) break; - } - } + { + while ((res = string_nextinlist(&ptr, &ipsep, ip, sizeof(ip)))) + if (Ustrcmp(CS da->address, ip) == 0) + break; + } /* Handle bitmask matching */ @@ -3493,7 +3487,7 @@ if (cb->rc == DNS_SUCCEED) /* Scan the returned addresses, skipping any that are IPv6 */ - while ((res = string_nextinlist(&ptr, &ipsep, ip, sizeof(ip))) != NULL) + while ((res = string_nextinlist(&ptr, &ipsep, ip, sizeof(ip)))) { if (host_aton(ip, address) != 1) continue; if ((address[0] & mask) == address[0]) break; @@ -3526,17 +3520,13 @@ if (cb->rc == DNS_SUCCEED) switch(match_type) { case 0: - res = US"was no match"; - break; + res = US"was no match"; break; case MT_NOT: - res = US"was an exclude match"; - break; + res = US"was an exclude match"; break; case MT_ALL: - res = US"was an IP address that did not match"; - break; + res = US"was an IP address that did not match"; break; case MT_NOT|MT_ALL: - res = US"were no IP addresses that did not match"; - break; + res = US"were no IP addresses that did not match"; break; } debug_printf("=> but we are not accepting this block class because\n"); debug_printf("=> there %s for %s%c%s\n", @@ -3568,15 +3558,15 @@ if (cb->rc == DNS_SUCCEED) { dns_record *rr; for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); - rr != NULL; + rr; rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT)) if (rr->type == T_TXT) break; - if (rr != NULL) + if (rr) { int len = (rr->data)[0]; if (len > 511) len = 127; store_pool = POOL_PERM; - cb->text = string_sprintf("%.*s", len, (const uschar *)(rr->data+1)); + cb->text = string_sprintf("%.*s", len, CUS (rr->data+1)); store_pool = old_pool; } } -- 2.30.2