From accf9211ea33262b8865805a4f61155f26320444 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 21 Apr 2020 23:21:24 +0100 Subject: [PATCH] tidying --- src/src/host.c | 23 +++++++++++------------ test/stderr/0388 | 2 ++ test/stderr/0398 | 3 +++ test/stderr/0432 | 2 ++ test/stderr/2202 | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/src/host.c b/src/src/host.c index 1426bff97..456365c8f 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -182,19 +182,18 @@ dns_scan dnss; DEBUG(D_host_lookup) debug_printf("using host_fake_gethostbyname for %s (%s)\n", name, - (af == AF_INET)? "IPv4" : "IPv6"); + af == AF_INET ? "IPv4" : "IPv6"); /* Handle unqualified "localhost" */ if (Ustrcmp(name, "localhost") == 0) - lname = (af == AF_INET)? US"127.0.0.1" : US"::1"; + lname = af == AF_INET ? US"127.0.0.1" : US"::1"; /* Handle a literal IP address */ if ((ipa = string_is_ip_address(lname, NULL)) != 0) - { - if ((ipa == 4 && af == AF_INET) || - (ipa == 6 && af == AF_INET6)) + if ( ipa == 4 && af == AF_INET + || ipa == 6 && af == AF_INET6) { int x[4]; yield = store_get(sizeof(struct hostent), FALSE); @@ -224,13 +223,12 @@ if ((ipa = string_is_ip_address(lname, NULL)) != 0) *error_num = HOST_NOT_FOUND; return NULL; } - } /* Handle a host name */ else { - int type = (af == AF_INET)? T_A:T_AAAA; + int type = af == AF_INET ? T_A:T_AAAA; int rc = dns_lookup_timerwrap(dnsa, lname, type, NULL); int count = 0; @@ -2035,7 +2033,7 @@ for (int i = 1; i <= times; && (time_msec = get_time_in_ms() - time_msec) > slow_lookup_log) log_long_lookup(US"gethostbyname", host->name, time_msec); - if (hostdata == NULL) + if (!hostdata) { uschar *error; switch (error_num) @@ -2044,18 +2042,19 @@ for (int i = 1; i <= times; case TRY_AGAIN: error = US"TRY_AGAIN"; break; case NO_RECOVERY: error = US"NO_RECOVERY"; break; case NO_DATA: error = US"NO_DATA"; break; - #if NO_DATA != NO_ADDRESS + #if NO_DATA != NO_ADDRESS case NO_ADDRESS: error = US"NO_ADDRESS"; break; - #endif + #endif default: error = US"?"; break; } DEBUG(D_host_lookup) debug_printf("%s returned %d (%s)\n", + f.running_in_test_harness ? "host_fake_gethostbyname" : #if HAVE_IPV6 #if HAVE_GETIPNODEBYNAME - (af == AF_INET6)? "getipnodebyname(af=inet6)" : "getipnodebyname(af=inet)", + af == AF_INET6 ? "getipnodebyname(af=inet6)" : "getipnodebyname(af=inet)", #else - (af == AF_INET6)? "gethostbyname2(af=inet6)" : "gethostbyname2(af=inet)", + af == AF_INET6 ? "gethostbyname2(af=inet6)" : "gethostbyname2(af=inet)", #endif #else "gethostbyname", diff --git a/test/stderr/0388 b/test/stderr/0388 index aba5a1158..4c833bea6 100644 --- a/test/stderr/0388 +++ b/test/stderr/0388 @@ -38,6 +38,7 @@ expanded list of hosts = '127.0.0.1 : V4NET.0.0.0' options = '' set transport smtp finding IP address for 127.0.0.1 calling host_find_byname +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address fully qualified name = 127.0.0.1 @@ -47,6 +48,7 @@ get[host|ipnode]byname[2] looked up these IP addresses: remote host address is the local host: y: configured to try delivery anyway finding IP address for V4NET.0.0.0 calling host_find_byname +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for V4NET.0.0.0 (IPv4) fully qualified name = V4NET.0.0.0 MUNGED: ::1 will be omitted in what follows diff --git a/test/stderr/0398 b/test/stderr/0398 index 4756ab053..24b04f402 100644 --- a/test/stderr/0398 +++ b/test/stderr/0398 @@ -52,6 +52,7 @@ expanded list of hosts = '127.0.0.1' options = '' set transport t2 finding IP address for 127.0.0.1 calling host_find_byname +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address fully qualified name = 127.0.0.1 @@ -100,6 +101,7 @@ original list of hosts = '127.0.0.1' options = '' expanded list of hosts = '127.0.0.1' options = '' finding IP address for 127.0.0.1 calling host_find_byname +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address fully qualified name = 127.0.0.1 @@ -214,6 +216,7 @@ original list of hosts = '127.0.0.1' options = '' expanded list of hosts = '127.0.0.1' options = '' finding IP address for 127.0.0.1 calling host_find_byname +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address fully qualified name = 127.0.0.1 diff --git a/test/stderr/0432 b/test/stderr/0432 index 0e6a1d952..b01205611 100644 --- a/test/stderr/0432 +++ b/test/stderr/0432 @@ -72,6 +72,7 @@ domain = y routed by r1 router envelope to: x@y transport: t1 +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address MUNGED: ::1 will be omitted in what follows @@ -182,6 +183,7 @@ domain = y routed by r1 router envelope to: x@y transport: t1 +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) using host_fake_gethostbyname for 127.0.0.1 (IPv4) local host found for non-MX address MUNGED: ::1 will be omitted in what follows diff --git a/test/stderr/2202 b/test/stderr/2202 index a20ef0331..3752ec538 100644 --- a/test/stderr/2202 +++ b/test/stderr/2202 @@ -66,7 +66,7 @@ cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*") cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH DNS: no SOA record found for neg-TTL writing neg-cache entry for cioce.test.again.dns-A-xxxx, ttl -1 -get[host|ipnode]byname[2] returned 1 (HOST_NOT_FOUND) +host_fake_gethostbyname returned 1 (HOST_NOT_FOUND) no IP address found for host cioce.test.again.dns (during SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4]) LOG: host_lookup_failed MAIN no IP address found for host cioce.test.again.dns (during SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4]) -- 2.30.2