[exim-cvs] tidying

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] tidying
Gitweb: https://git.exim.org/exim.git/commitdiff/96c8151125ceb98ed52c0089f6401e6ba05bb41e
Commit:     96c8151125ceb98ed52c0089f6401e6ba05bb41e
Parent:     8e9fdd6369f0a7a81f0ca195e24edd372f7ca3ef
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Wed Mar 18 11:36:59 2020 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Mar 18 11:42:14 2020 +0000


    tidying
---
 src/src/child.c           | 16 ++++++++--------
 src/src/daemon.c          |  4 ++--
 src/src/exim.c            |  8 +++-----
 src/src/log.c             |  6 ++++--
 src/src/transport.c       | 11 +++++++----
 src/src/transports/smtp.c |  4 ++--
 test/stderr/0393          |  2 +-
 7 files changed, 27 insertions(+), 24 deletions(-)


diff --git a/src/src/child.c b/src/src/child.c
index f6d44e1..13d177c 100644
--- a/src/src/child.c
+++ b/src/src/child.c
@@ -240,7 +240,7 @@ if (pid == 0)
   if (debug_fd > 0) force_fd(debug_fd, 2);
   if (f.running_in_test_harness && !queue_only)
     {
-    if (sender_authentication != NULL)
+    if (sender_authentication)
       child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 9,
         US "-odi", US"-t", US"-oem", US"-oi", US"-f", sender, US"-oMas",
         sender_authentication, message_id_option);
@@ -252,7 +252,7 @@ if (pid == 0)
     }
   else   /* Not test harness */
     {
-    if (sender_authentication != NULL)
+    if (sender_authentication)
       child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 8,
         US"-t", US"-oem", US"-oi", US"-f", sender, US"-oMas",
         sender_authentication, message_id_option);
@@ -341,7 +341,7 @@ that the child process can be waited for. We sometimes get here with it set
 otherwise. Save the old state for resetting on the wait. */


 oldsignal = signal(SIGCHLD, SIG_DFL);
-pid = exim_fork(US"queryprogram");    /* queryprogram tpt is sole caller */
+pid = exim_fork(US"child-open");


/* Handle the child process. First, set the required environment. We must do
this before messing with the pipes, in order to be able to write debugging
@@ -352,14 +352,14 @@ if (pid == 0)
signal(SIGUSR1, SIG_IGN);
signal(SIGPIPE, SIG_DFL);

-  if (newgid != NULL && setgid(*newgid) < 0)
+  if (newgid && setgid(*newgid) < 0)
     {
     DEBUG(D_any) debug_printf("failed to set gid=%ld in subprocess: %s\n",
       (long int)(*newgid), strerror(errno));
     goto CHILD_FAILED;
     }


-  if (newuid != NULL && setuid(*newuid) < 0)
+  if (newuid && setuid(*newuid) < 0)
     {
     DEBUG(D_any) debug_printf("failed to set uid=%ld in subprocess: %s\n",
       (long int)(*newuid), strerror(errno));
@@ -368,7 +368,7 @@ if (pid == 0)


(void)umask(newumask);

-  if (wd != NULL && Uchdir(wd) < 0)
+  if (wd && Uchdir(wd) < 0)
     {
     DEBUG(D_any) debug_printf("failed to chdir to %s: %s\n", wd,
       strerror(errno));
@@ -398,8 +398,8 @@ if (pid == 0)


/* Now do the exec */

- if (envp == NULL) execv(CS argv[0], (char *const *)argv);
- else execve(CS argv[0], (char *const *)argv, (char *const *)envp);
+ if (envp) execve(CS argv[0], (char *const *)argv, (char *const *)envp);
+ else execv(CS argv[0], (char *const *)argv);

   /* Failed to execv. Signal this failure using EX_EXECFAILED. We are
   losing the actual errno we got back, because there is no way to return
diff --git a/src/src/daemon.c b/src/src/daemon.c
index a1ef1f9..81fb694 100644
--- a/src/src/daemon.c
+++ b/src/src/daemon.c
@@ -2127,8 +2127,8 @@ for (;;)
       have enough queue runners on the go. If we are not running as root, a
       re-exec is required. */


-      if (queue_interval > 0 &&
-         (local_queue_run_max <= 0 || queue_run_count < local_queue_run_max))
+      if (  queue_interval > 0
+         && (local_queue_run_max <= 0 || queue_run_count < local_queue_run_max))
         {
         if ((pid = exim_fork(US"queue runner")) == 0)
           {
diff --git a/src/src/exim.c b/src/src/exim.c
index 6bde8fd..f7f8b25 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -342,11 +342,9 @@ Returns:     nothing
 void
 millisleep(int msec)
 {
-struct itimerval itval;
-itval.it_interval.tv_sec = 0;
-itval.it_interval.tv_usec = 0;
-itval.it_value.tv_sec = msec/1000;
-itval.it_value.tv_usec = (msec % 1000) * 1000;
+struct itimerval itval = {.it_interval = {.tv_sec = 0, .tv_usec = 0},
+              .it_value = {.tv_sec = msec/1000,
+                       .tv_usec = (msec % 1000) * 1000}};
 milliwait(&itval);
 }


diff --git a/src/src/log.c b/src/src/log.c
index e80c177..89c5dc0 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -510,7 +510,7 @@ non-setuid binary with log_arguments set, called in certain ways.) Rather than
just bombing out, force the log to stderr and carry on if stderr is available.
*/

-if (euid != root_uid && euid != exim_uid && log_stderr != NULL)
+if (euid != root_uid && euid != exim_uid && log_stderr)
{
*fd = fileno(log_stderr);
return;
@@ -519,7 +519,9 @@ if (euid != root_uid && euid != exim_uid && log_stderr != NULL)
/* Otherwise this is a disaster. This call is deliberately ONLY to the panic
log. If possible, save a copy of the original line that was being logged. If we
are recursing (can't open the panic log either), the pointer will already be
-set. */
+set. Also, when we had to use a subprocess for the create we didn't retrieve
+errno from it, so get the error from the open attempt above (which is often
+meaningful enough, so leave it). */

if (!panic_save_buffer)
if ((panic_save_buffer = US malloc(LOG_BUFFER_SIZE)))
diff --git a/src/src/transport.c b/src/src/transport.c
index d92ad4c..142fede 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -1188,7 +1188,8 @@ transport_write_message(transport_ctx * tctx, int size_limit)
{
BOOL last_filter_was_NL = TRUE;
BOOL save_spool_file_wireformat = f.spool_file_wireformat;
-int rc, len, yield, fd_read, fd_write, save_errno;
+BOOL yield;
+int rc, len, fd_read, fd_write, save_errno;
int pfd[2] = {-1, -1};
pid_t filter_pid, write_pid;

@@ -1248,7 +1249,7 @@ via a(nother) pipe. While writing to the filter, we do not do the CRLF,
smtp dots, or check string processing. */

 if (pipe(pfd) != 0) goto TIDY_UP;      /* errno set */
-if ((write_pid = exim_fork(US"transport filter")) == 0)
+if ((write_pid = exim_fork(US"transport filter writer")) == 0)
   {
   BOOL rc;
   (void)close(fd_read);
@@ -1272,7 +1273,7 @@ if ((write_pid = exim_fork(US"transport filter")) == 0)
         != sizeof(struct timeval)
      )
     rc = FALSE;    /* compiler quietening */
-  exim_underbar_exit(0, US"tpt-filter");
+  exim_underbar_exit(0, US"tpt-filter writer");
   }
 save_errno = errno;


@@ -1320,6 +1321,7 @@ for (;;)
   ALARM_CLR(0);
   if (sigalrm_seen)
     {
+    DEBUG(D_transport) debug_printf("timed out reading from filter\n");
     errno = ETIMEDOUT;
     f.transport_filter_timed_out = TRUE;
     goto TIDY_UP;
@@ -1438,7 +1440,7 @@ DEBUG(D_transport)
   {
   debug_printf("end of filtering transport writing: yield=%d\n", yield);
   if (!yield)
-    debug_printf("errno=%d more_errno=%d\n", errno, tctx->addr->more_errno);
+    debug_printf(" errno=%d more_errno=%d\n", errno, tctx->addr->more_errno);
   }


 return yield;
@@ -1731,6 +1733,7 @@ while (1)
     }


/* first thing remove current message id if it exists */
+ /*XXX but what if it has un-sent addrs? */

   for (i = 0; i < msgq_count; ++i)
     if (Ustrcmp(msgq[i].message_id, message_id) == 0)
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 459110b..7be9e8e 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -1685,7 +1685,7 @@ current_local_identity =
   smtp_local_identity(s_compare->current_sender_address, s_compare->tblock);


 if (!(new_sender_address = deliver_get_sender_address(message_id)))
-    return 0;
+    return FALSE;


message_local_identity =
smtp_local_identity(new_sender_address, s_compare->tblock);
@@ -3459,7 +3459,7 @@ if ((rc = smtp_setup_conn(sx, suppress_tls)) != OK)
}

/* If there is a filter command specified for this transport, we can now
-set it up. This cannot be done until the identify of the host is known. */
+set it up. This cannot be done until the identity of the host is known. */

if (tblock->filter_command)
{
diff --git a/test/stderr/0393 b/test/stderr/0393
index 5640078..79e68be 100644
--- a/test/stderr/0393
+++ b/test/stderr/0393
@@ -31,7 +31,7 @@ writing data block fd=dddd size=sss timeout=0
process pppp running as transport filter: fd_write=dddd fd_read=dddd
cannot use sendfile for body: spoolfile not wireformat
writing data block fd=dddd size=sss timeout=0
->>>>>>>>>>>>>>>> Exim pid=pppp (tpt-filter) terminating with rc=0 >>>>>>>>>>>>>>>>
+>>>>>>>>>>>>>>>> Exim pid=pppp (tpt-filter writer) terminating with rc=0 >>>>>>>>>>>>>>>>
process pppp writing to transport filter
copying from the filter
waiting for filter process