From 8c513105fde2b8be3397216a0153f9b266fc7dfb Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 15 Nov 2018 15:08:53 +0000 Subject: [PATCH] tidying --- src/src/expand.c | 2 +- src/src/host.c | 33 +++++++++++---------------------- src/src/log.c | 1 - src/src/receive.c | 4 ++-- src/src/routers/manualroute.c | 16 ++++++++-------- src/src/smtp_in.c | 6 ++---- src/src/string.c | 6 ++---- 7 files changed, 26 insertions(+), 42 deletions(-) diff --git a/src/src/expand.c b/src/src/expand.c index 0edd95dff..2be7f9094 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1957,7 +1957,7 @@ switch (vp->type) case vtype_pspace: { int inodes; - sprintf(CS var_buffer, "%d", + sprintf(CS var_buffer, PR_EXIM_ARITH, receive_statvfs(val == (void *)TRUE, &inodes)); } return var_buffer; diff --git a/src/src/host.c b/src/src/host.c index c3694c047..06cfe338c 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -2788,8 +2788,7 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); rr; rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT)) if (rr->type == ind_type) { - int precedence; - int weight = 0; /* For SRV records */ + int precedence, weight; int port = PORT_NONE; const uschar * s = rr->data; /* MUST be unsigned for GETSHORT */ uschar data[256]; @@ -2801,13 +2800,11 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); if (ind_type == T_MX) weight = random_number(500); - - /* SRV records are specified with a port and a weight. The weight is used - in a special algorithm. However, to start with, we just use it to order the - records of equal priority (precedence). */ - else { + /* SRV records are specified with a port and a weight. The weight is used + in a special algorithm. However, to start with, we just use it to order the + records of equal priority (precedence). */ GETSHORT(weight, s); GETSHORT(port, s); } @@ -2822,17 +2819,16 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); never know what junk might get into the DNS (and this case has been seen on more than one occasion). */ - if (last != NULL) /* This is not the first record */ + if (last) /* This is not the first record */ { host_item *prev = NULL; for (h = host; h != last->next; prev = h, h = h->next) - { if (strcmpic(h->name, data) == 0) { DEBUG(D_host_lookup) debug_printf("discarded duplicate host %s (MX=%d)\n", data, - (precedence > h->mx)? precedence : h->mx); + precedence > h->mx ? precedence : h->mx); if (precedence >= h->mx) goto NEXT_MX_RR; /* Skip greater precedence */ if (h == host) /* Override first item */ { @@ -2848,7 +2844,6 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); if (h == last) last = prev; break; } - } } /* If this is the first MX or SRV record, put the data into the existing host @@ -2867,10 +2862,9 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); host->dnssec = dnssec; last = host; } + else /* Make a new host item and seek the correct insertion place */ - - else { int sort_key = precedence * 1000 + weight; host_item *next = store_get(sizeof(host_item)); @@ -2895,21 +2889,18 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); host->next = next; if (last == host) last = next; } + else /* Else scan down the items we have inserted as part of this exercise; don't go further. */ - - else { for (h = host; h != last; h = h->next) - { if (sort_key < h->next->sort_key) { next->next = h->next; h->next = next; break; } - } /* Join on after the last host item that's part of this processing if we haven't stopped sooner. */ @@ -2986,10 +2977,9 @@ if (ind_type == T_SRV) for (ppptr = pptr, hhh = h; hhh != hh; - ppptr = &(hhh->next), hhh = hhh->next) - { - if (hhh->sort_key >= randomizer) break; - } + ppptr = &hhh->next, hhh = hhh->next) + if (hhh->sort_key >= randomizer) + break; /* hhh now points to the host that should go first; ppptr points to the place that points to it. Unfortunately, if the start of the minilist is @@ -3014,7 +3004,6 @@ if (ind_type == T_SRV) hhh->next = temp.next; h->next = hhh; } - else { hhh->next = h; /* The rest of the chain follows it */ diff --git a/src/src/log.c b/src/src/log.c index 3fdcbbee9..d08200044 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -736,7 +736,6 @@ Returns: nothing void log_write(unsigned int selector, int flags, const char *format, ...) { -uschar * ptr; int paniclogfd; ssize_t written_len; gstring gs = { .size = LOG_BUFFER_SIZE-1, .ptr = 0, .s = log_buffer }; diff --git a/src/src/receive.c b/src/src/receive.c index e9877d3a0..93b350a65 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -273,8 +273,8 @@ if (check_spool_space > 0 || msg_size > 0 || check_spool_inodes > 0) if ((space >= 0 && space < check_spool_space) || (inodes >= 0 && inodes < check_spool_inodes)) { - log_write(0, LOG_MAIN, "spool directory space check failed: space=%d " - "inodes=%d", space, inodes); + log_write(0, LOG_MAIN, "spool directory space check failed: space=" + PR_EXIM_ARITH " inodes=%d", space, inodes); return FALSE; } } diff --git a/src/src/routers/manualroute.c b/src/src/routers/manualroute.c index af4470655..e327b7c6f 100644 --- a/src/src/routers/manualroute.c +++ b/src/src/routers/manualroute.c @@ -159,15 +159,15 @@ parse_route_item(const uschar *s, const uschar **domain, const uschar **hostlist { while (*s != 0 && isspace(*s)) s++; -if (domain != NULL) +if (domain) { - if (*s == 0) return FALSE; /* missing data */ + if (!*s) return FALSE; /* missing data */ *domain = string_dequote(&s); - while (*s != 0 && isspace(*s)) s++; + while (*s && isspace(*s)) s++; } *hostlist = string_dequote(&s); -while (*s != 0 && isspace(*s)) s++; +while (*s && isspace(*s)) s++; *options = s; return TRUE; } @@ -261,7 +261,7 @@ DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n", /* The initialization check ensures that either route_list or route_data is set. */ -if (ob->route_list != NULL) +if (ob->route_list) { int sep = -(';'); /* Default is semicolon */ listptr = ob->route_list; @@ -289,7 +289,7 @@ if (ob->route_list != NULL) } } - if (route_item == NULL) return DECLINE; /* No pattern in the list matched */ + if (!route_item) return DECLINE; /* No pattern in the list matched */ } /* Handle a single routing item in route_data. If it expands to an empty @@ -297,8 +297,8 @@ string, decline. */ else { - route_item = rf_expand_data(addr, ob->route_data, &rc); - if (route_item == NULL) return rc; + if (!(route_item = rf_expand_data(addr, ob->route_data, &rc))) + return rc; (void) parse_route_item(route_item, NULL, &hostlist, &options); if (hostlist[0] == 0) return DECLINE; } diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index dbd428011..e9e817798 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -3485,7 +3485,7 @@ int rc; uschar *user_msg = NULL; uschar *log_msg = NULL; -/* Check for recursive acll */ +/* Check for recursive call */ if (fl.smtp_exit_function_called) { @@ -3510,9 +3510,7 @@ if (acl_smtp_notquit && reason) tls_in.active.sock = -1; /* Write an SMTP response if we are expected to give one. As the default -responses are all internal, they should always fit in the buffer, but code a -warning, just in case. Note that string_vformat() still leaves a complete -string, even if it is incomplete. */ +responses are all internal, they should be reasonable size. */ if (code && defaultrespond) { diff --git a/src/src/string.c b/src/src/string.c index 914030775..332047460 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -651,18 +651,16 @@ uschar *t, *yield; /* First find the end of the string */ if (*s != '\"') - { while (*s != 0 && !isspace(*s)) s++; - } else { s++; - while (*s != 0 && *s != '\"') + while (*s && *s != '\"') { if (*s == '\\') (void)string_interpret_escape(&s); s++; } - if (*s != 0) s++; + if (*s) s++; } /* Get enough store to copy into */ -- 2.30.2