tidying
authorJeremy Harris <jgh146exb@wizmail.org>
Mon, 6 Feb 2017 13:07:42 +0000 (13:07 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 24 Feb 2017 15:38:50 +0000 (15:38 +0000)
src/src/acl.c
src/src/daemon.c
src/src/deliver.c
src/src/expand.c
src/src/pdkim/pdkim.c
src/src/smtp_in.c
src/src/tree.c

index 60fa9775259ff55f4362bf48098672f01bbb40cc..efab1d31e22691cdfa917ff229136af8338d5b09 100644 (file)
@@ -4351,7 +4351,7 @@ switch (where)
        if (*--s && isdigit(*s) && *--s && isdigit(*s)) *user_msgptr = s;
        acl_temp_details = TRUE;
        }
-       else
+      else
        {
        HDEBUG(D_acl) debug_printf_indent("cutthrough defer; will spool\n");
        rc = OK;
@@ -4425,12 +4425,10 @@ Returns   the pointer to variable's tree node
 */
 
 tree_node *
-acl_var_create(uschar *name)
+acl_var_create(uschar * name)
 {
-tree_node *node, **root;
-root = (name[0] == 'c')? &acl_var_c : &acl_var_m;
-node = tree_search(*root, name);
-if (node == NULL)
+tree_node * node, ** root = name[0] == 'c' ? &acl_var_c : &acl_var_m;
+if (!(node = tree_search(*root, name)))
   {
   node = store_get(sizeof(tree_node) + Ustrlen(name));
   Ustrcpy(node->name, name);
index ea0c2226259f062a5778c9441275fcde70aea82e..e9ecbe7d6e1106a096ef3e3be416a38708593d12 100644 (file)
@@ -542,9 +542,9 @@ if (pid == 0)
     DEBUG(D_receive)
       {
       int i;
-      if (sender_address != NULL)
+      if (sender_address)
         debug_printf("Sender: %s\n", sender_address);
-      if (recipients_list != NULL)
+      if (recipients_list)
         {
         debug_printf("Recipients:\n");
         for (i = 0; i < recipients_count; i++)
index c97874a2b6c328bd3d0b1c0598b5a9e7076e6d70..c416ebf3fd78f79e11a864c8ae50eeb28fc82711 100644 (file)
@@ -3238,7 +3238,7 @@ uschar *endptr = big_buffer;
 uschar *ptr = endptr;
 uschar *msg = p->msg;
 BOOL done = p->done;
-BOOL unfinished = TRUE;
+BOOL finished = FALSE;
 /* minimum size to read is header size including id, subid and length */
 int required = PIPE_HEADER_SIZE;
 
@@ -3271,7 +3271,7 @@ while (!done)
   There will be only one read if we get all the available data (i.e. don't
   fill the buffer completely). */
 
-  if (remaining < required && unfinished)
+  if (remaining < required && !finished)
     {
     int len;
     int available = big_buffer_size - remaining;
@@ -3301,11 +3301,11 @@ while (!done)
     /* If the length is zero (eof or no-more-data), just process what we
     already have. Note that if the process is still running and we have
     read all the data in the pipe (but less that "available") then we
-    won't read any more, as "unfinished" will get set FALSE. */
+    won't read any more, as "finished" will get set. */
 
     endptr += len;
     remaining += len;
-    unfinished = len == available;
+    finished = len != available;
     }
 
   /* If we are at the end of the available data, exit the loop. */
@@ -3326,8 +3326,8 @@ while (!done)
     }
 
   DEBUG(D_deliver)
-    debug_printf("header read  id:%c,subid:%c,size:%s,required:%d,remaining:%d,unfinished:%d\n",
-                    id, subid, header+2, required, remaining, unfinished);
+    debug_printf("header read  id:%c,subid:%c,size:%s,required:%d,remaining:%d,finished:%d\n",
+                    id, subid, header+2, required, remaining, finished);
 
   /* is there room for the dataset we want to read ? */
   if (required > big_buffer_size - PIPE_HEADER_SIZE)
@@ -3339,22 +3339,22 @@ while (!done)
     break;
     }
 
-  /* we wrote all datasets with atomic write() calls
-     remaining < required only happens if big_buffer was too small
-     to get all available data from pipe. unfinished has to be true
-     as well. */
+  /* We wrote all datasets with atomic write() calls.  Remaining < required only
+  happens if big_buffer was too small to get all available data from pipe;
+  finished has to be false as well. */
+
   if (remaining < required)
     {
-    if (unfinished)
+    if (!finished)
       continue;
     msg = string_sprintf("failed to read pipe from transport process "
-      "%d for transport %s: required size=%d > remaining size=%d and unfinished=false",
+      "%d for transport %s: required size=%d > remaining size=%d and finished=true",
       pid, addr->transport->driver_name, required, remaining);
     done = TRUE;
     break;
     }
 
-  /* step behind the header */
+  /* Step past the header */
   ptr += PIPE_HEADER_SIZE;
 
   /* Handle each possible type of item, assuming the complete item is
index 55fb0b875cb4136ee418282aa3742369da412163..6257c28b70baa1cbe8b903d463d585240e099535 100644 (file)
@@ -6745,12 +6745,11 @@ while (*s != 0)
       case EOP_LOCAL_PART:
       case EOP_DOMAIN:
         {
-        uschar *error;
+        uschar * error;
         int start, end, domain;
-        uschar *t = parse_extract_address(sub, &error, &start, &end, &domain,
+        uschar * t = parse_extract_address(sub, &error, &start, &end, &domain,
           FALSE);
-        if (t != NULL)
-          {
+        if (t)
           if (c != EOP_DOMAIN)
             {
             if (c == EOP_LOCAL_PART && domain != 0) end = start + domain - 1;
@@ -6761,7 +6760,6 @@ while (*s != 0)
             domain += start;
             yield = string_catn(yield, &size, &ptr, sub+domain, end-domain);
             }
-          }
         continue;
         }
 
index 4c93de70dd1e14124125bcb41626d82d940f121c..f26b745af31a84af274579eaeb18282526d49ef0 100644 (file)
@@ -416,7 +416,7 @@ return b64encode(b->data, b->len);
 static pdkim_signature *
 pdkim_parse_sig_header(pdkim_ctx *ctx, uschar * raw_hdr)
 {
-pdkim_signature *sig ;
+pdkim_signature * sig;
 uschar *p, *q;
 uschar * cur_tag = NULL; int ts = 0, tl = 0;
 uschar * cur_val = NULL; int vs = 0, vl = 0;
@@ -931,28 +931,25 @@ return PDKIM_OK;
 #define DKIM_SIGNATURE_HEADERNAME "DKIM-Signature:"
 
 static int
-pdkim_header_complete(pdkim_ctx *ctx)
+pdkim_header_complete(pdkim_ctx * ctx)
 {
+pdkim_signature * sig, * last_sig;
+
 /* Special case: The last header can have an extra \r appended */
 if ( (ctx->cur_header_len > 1) &&
      (ctx->cur_header[(ctx->cur_header_len)-1] == '\r') )
   --ctx->cur_header_len;
 ctx->cur_header[ctx->cur_header_len] = '\0';
 
-ctx->num_headers++;
-if (ctx->num_headers > PDKIM_MAX_HEADERS) goto BAIL;
+if (++ctx->num_headers > PDKIM_MAX_HEADERS) goto BAIL;
 
 /* SIGNING -------------------------------------------------------------- */
 if (ctx->flags & PDKIM_MODE_SIGN)
-  {
-  pdkim_signature *sig;
-
   for (sig = ctx->sig; sig; sig = sig->next)                   /* Traverse all signatures */
 
     /* Add header to the signed headers list (in reverse order) */
     sig->headers = pdkim_prepend_stringlist(sig->headers,
                                  ctx->cur_header);
-  }
 
 /* VERIFICATION ----------------------------------------------------------- */
 /* DKIM-Signature: headers are added to the verification list */
@@ -962,15 +959,13 @@ else
   DEBUG(D_acl)
     {
     debug_printf("PDKIM >> raw hdr: ");
-    pdkim_quoteprint(CUS ctx->cur_header, Ustrlen(ctx->cur_header));
+    pdkim_quoteprint(CUS ctx->cur_header, ctx->cur_header_len);
     }
 #endif
   if (strncasecmp(CCS ctx->cur_header,
                  DKIM_SIGNATURE_HEADERNAME,
                  Ustrlen(DKIM_SIGNATURE_HEADERNAME)) == 0)
     {
-    pdkim_signature * new_sig, * last_sig;
-
     /* Create and chain new signature block.  We could error-check for all
     required tags here, but prefer to create the internal sig and expicitly
     fail verification of it later. */
@@ -978,14 +973,14 @@ else
     DEBUG(D_acl) debug_printf(
        "PDKIM >> Found sig, trying to parse >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
 
-    new_sig = pdkim_parse_sig_header(ctx, ctx->cur_header);
+    sig = pdkim_parse_sig_header(ctx, ctx->cur_header);
 
     if (!(last_sig = ctx->sig))
-      ctx->sig = new_sig;
+      ctx->sig = sig;
     else
       {
       while (last_sig->next) last_sig = last_sig->next;
-      last_sig->next = new_sig;
+      last_sig->next = sig;
       }
     }
 
@@ -994,8 +989,7 @@ else
   }
 
 BAIL:
-*ctx->cur_header = '\0';
-ctx->cur_header_len = 0;       /* leave buffer for reuse */
+ctx->cur_header[ctx->cur_header_len = 0] = '\0';       /* leave buffer for reuse */
 return PDKIM_OK;
 }
 
index 4cda753e8550bf78bb55bf5841a4d75703fac5fc..f0885b3a13b1ca6c65a3effe44f97d1ea9ef2e6c 100644 (file)
@@ -949,43 +949,45 @@ Return the amount read.
 static int
 swallow_until_crlf(int fd, uschar *base, int already, int capacity)
 {
-  uschar *to = base + already;
-  uschar *cr;
-  int have = 0;
-  int ret;
-  int last = 0;
-
-  /* For "PROXY UNKNOWN\r\n" we, at time of writing, expect to have read
-  up through the \r; for the _normal_ case, we haven't yet seen the \r. */
-  cr = memchr(base, '\r', already);
-  if (cr != NULL)
-    {
-    if ((cr - base) < already - 1)
-      {
-      /* \r and presumed \n already within what we have; probably not
-      actually proxy protocol, but abort cleanly. */
-      return 0;
-      }
-    /* \r is last character read, just need one more. */
-    last = 1;
-    }
+uschar *to = base + already;
+uschar *cr;
+int have = 0;
+int ret;
+int last = 0;
+
+/* For "PROXY UNKNOWN\r\n" we, at time of writing, expect to have read
+up through the \r; for the _normal_ case, we haven't yet seen the \r. */
 
-  while (capacity > 0)
+cr = memchr(base, '\r', already);
+if (cr != NULL)
+  {
+  if ((cr - base) < already - 1)
     {
-    do { ret = recv(fd, to, 1, 0); } while (ret == -1 && errno == EINTR);
-    if (ret == -1)
-      return -1;
-    have++;
-    if (last)
-      return have;
-    if (*to == '\r')
-      last = 1;
-    capacity--;
-    to++;
+    /* \r and presumed \n already within what we have; probably not
+    actually proxy protocol, but abort cleanly. */
+    return 0;
     }
-  // reached end without having room for a final newline, abort
-  errno = EOVERFLOW;
-  return -1;
+  /* \r is last character read, just need one more. */
+  last = 1;
+  }
+
+while (capacity > 0)
+  {
+  do { ret = recv(fd, to, 1, 0); } while (ret == -1 && errno == EINTR);
+  if (ret == -1)
+    return -1;
+  have++;
+  if (last)
+    return have;
+  if (*to == '\r')
+    last = 1;
+  capacity--;
+  to++;
+  }
+
+/* reached end without having room for a final newline, abort */
+errno = EOVERFLOW;
+return -1;
 }
 
 /*************************************************
@@ -1093,9 +1095,9 @@ if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CS &tv, sizeof(tv)) < 0)
 do
   {
   /* The inbound host was declared to be a Proxy Protocol host, so
-     don't do a PEEK into the data, actually slurp up enough to be
-     "safe". Can't take it all because TLS-on-connect clients follow
-     immediately with TLS handshake. */
+  don't do a PEEK into the data, actually slurp up enough to be
+  "safe". Can't take it all because TLS-on-connect clients follow
+  immediately with TLS handshake. */
   ret = recv(fd, &hdr, PROXY_INITIAL_READ, 0);
   }
   while (ret == -1 && errno == EINTR);
@@ -1121,9 +1123,9 @@ if ((ret == PROXY_INITIAL_READ) && (memcmp(&hdr.v2, v2sig, sizeof(v2sig)) == 0))
   ver = (hdr.v2.ver_cmd & 0xf0) >> 4;
 
   /* May 2014: haproxy combined the version and command into one byte to
-     allow two full bytes for the length field in order to proxy SSL
-     connections.  SSL Proxy is not supported in this version of Exim, but
-     must still separate values here. */
+  allow two full bytes for the length field in order to proxy SSL
+  connections.  SSL Proxy is not supported in this version of Exim, but
+  must still separate values here. */
 
   if (ver != 0x02)
     {
@@ -1270,7 +1272,7 @@ else if (ret >= 8 && memcmp(hdr.v1.line, "PROXY", 5) == 0)
   DEBUG(D_receive) debug_printf("Detected PROXYv1 header\n");
   DEBUG(D_receive) debug_printf("Bytes read not within PROXY header: %d\n", ret - size);
   /* Step through the string looking for the required fields. Ensure
-     strict adherence to required formatting, exit for any error. */
+  strict adherence to required formatting, exit for any error. */
   p += 5;
   if (!isspace(*(p++)))
     {
index 72c084a6eeb69e8b74cb4d7e25c78cf193baaaf9..3b6c3603b0f0770ff5fc0d761f9dced6c757c762 100644 (file)
@@ -330,11 +330,11 @@ Returns:    pointer to node, or NULL if not found
 tree_node *
 tree_search(tree_node *p, const uschar *name)
 {
-while (p != NULL)
+while (p)
   {
   int c = Ustrcmp(name, p->name);
   if (c == 0) return p;
-  p = (c < 0)? p->left : p->right;
+  p = c < 0 ? p->left : p->right;
   }
 return NULL;
 }
@@ -355,10 +355,10 @@ Arguments:
 void
 tree_walk(tree_node *p, void (*f)(uschar*, uschar*, void*), void *ctx)
 {
-if (p == NULL) return;
+if (!p) return;
 f(p->name, p->data.ptr, ctx);
-if (p->left != NULL) tree_walk(p->left, f, ctx);
-if (p->right != NULL) tree_walk(p->right, f, ctx);
+tree_walk(p->left, f, ctx);
+tree_walk(p->right, f, ctx);
 }