[exim-cvs] tidying

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] tidying
Gitweb: https://git.exim.org/exim.git/commitdiff/870ce70e11912e8858ef4c071f2778b93a4b2ac9
Commit:     870ce70e11912e8858ef4c071f2778b93a4b2ac9
Parent:     7a66b3afa11a70021297c176acf56831692be89a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Oct 24 10:03:19 2019 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Jan 15 09:46:55 2020 +0000


    tidying
---
 src/src/auths/heimdal_gssapi.c | 46 +++++++++++++++++-------------------------
 src/src/exim_dbmbuild.c        | 18 ++++++++---------
 src/src/lookups/ldap.c         | 20 +++++++++---------
 src/src/spool_in.c             | 30 +++++++++++++--------------
 4 files changed, 50 insertions(+), 64 deletions(-)


diff --git a/src/src/auths/heimdal_gssapi.c b/src/src/auths/heimdal_gssapi.c
index 523f7c6..82eb6a3 100644
--- a/src/src/auths/heimdal_gssapi.c
+++ b/src/src/auths/heimdal_gssapi.c
@@ -134,10 +134,9 @@ if (!ob->server_service || !*ob->server_service)
{
HDEBUG(D_auth) debug_printf("heimdal: missing server_service\n");
return;
-}
+ }

-krc = krb5_init_context(&context);
-if (krc != 0)
+if ((krc = krb5_init_context(&context)))
   {
   int kerr = errno;
   HDEBUG(D_auth) debug_printf("heimdal: failed to initialise krb5 context: %s\n",
@@ -149,8 +148,7 @@ if (ob->server_keytab)
   {
   k_keytab_typed_name = CCS string_sprintf("file:%s", expand_string(ob->server_keytab));
   HDEBUG(D_auth) debug_printf("heimdal: using keytab %s\n", k_keytab_typed_name);
-  krc = krb5_kt_resolve(context, k_keytab_typed_name, &keytab);
-  if (krc)
+  if ((krc = krb5_kt_resolve(context, k_keytab_typed_name, &keytab)))
     {
     HDEBUG(D_auth) exim_heimdal_error_debug("krb5_kt_resolve", context, krc);
     return;
@@ -159,8 +157,7 @@ if (ob->server_keytab)
 else
  {
   HDEBUG(D_auth) debug_printf("heimdal: using system default keytab\n");
-  krc = krb5_kt_default(context, &keytab);
-  if (krc)
+  if ((krc = krb5_kt_default(context, &keytab)))
     {
     HDEBUG(D_auth) exim_heimdal_error_debug("krb5_kt_default", context, krc);
     return;
@@ -170,12 +167,11 @@ else
 HDEBUG(D_auth)
   {
   /* http://www.h5l.org/manual/HEAD/krb5/krb5_keytab_intro.html */
-  krc = krb5_kt_start_seq_get(context, keytab, &cursor);
-  if (krc)
+  if ((krc = krb5_kt_start_seq_get(context, keytab, &cursor)))
     exim_heimdal_error_debug("krb5_kt_start_seq_get", context, krc);
   else
     {
-    while ((krc = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0)
+    while (!(krc = krb5_kt_next_entry(context, keytab, &entry, &cursor)))
       {
       principal = enctype_s = NULL;
       krb5_unparse_name(context, entry.principal, &principal);
@@ -188,14 +184,12 @@ HDEBUG(D_auth)
       free(enctype_s);
       krb5_kt_free_entry(context, &entry);
       }
-    krc = krb5_kt_end_seq_get(context, keytab, &cursor);
-    if (krc)
+    if ((krc = krb5_kt_end_seq_get(context, keytab, &cursor)))
       exim_heimdal_error_debug("krb5_kt_end_seq_get", context, krc);
     }
   }


-krc = krb5_kt_close(context, keytab);
-if (krc)
+if ((krc = krb5_kt_close(context, keytab)))
HDEBUG(D_auth) exim_heimdal_error_debug("krb5_kt_close", context, krc);

 krb5_free_context(context);
@@ -317,7 +311,7 @@ while (step < 4)
   switch (step)
     {
     case 0:
-      if (!from_client || *from_client == '\0')
+      if (!from_client || !*from_client)
         {
     if (handled_empty_ir)
       {
@@ -325,15 +319,13 @@ while (step < 4)
       error_out = BAD64;
       goto ERROR_OUT;
       }
-    else
-      {
-      HDEBUG(D_auth) debug_printf("gssapi: missing initial response, nudging.\n");
-      error_out = auth_get_data(&from_client, US"", 0);
-      if (error_out != OK)
-        goto ERROR_OUT;
-      handled_empty_ir = TRUE;
-      continue;
-      }
+
+    HDEBUG(D_auth) debug_printf("gssapi: missing initial response, nudging.\n");
+    error_out = auth_get_data(&from_client, US"", 0);
+    if (error_out != OK)
+      goto ERROR_OUT;
+    handled_empty_ir = TRUE;
+    continue;
     }
       /* We should now have the opening data from the client, base64-encoded. */
       step += 1;
@@ -451,7 +443,7 @@ while (step < 4)
     }


       requested_qop = (CS gbufdesc_out.value)[0];
-      if ((requested_qop & 0x01) == 0)
+      if (!(requested_qop & 0x01))
         {
     HDEBUG(D_auth)
       debug_printf("gssapi: client requested security layers (%x)\n",
@@ -483,9 +475,7 @@ while (step < 4)


       /* $auth1 is GSSAPI display name */
       maj_stat = gss_display_name(&min_stat,
-      gclient,
-      &gbufdesc_out,
-      &mech_type);
+      gclient, &gbufdesc_out, &mech_type);
       if (GSS_ERROR(maj_stat))
         {
     auth_vars[1] = expand_nstring[2] = NULL;
diff --git a/src/src/exim_dbmbuild.c b/src/src/exim_dbmbuild.c
index 1185cfa..02da079 100644
--- a/src/src/exim_dbmbuild.c
+++ b/src/src/exim_dbmbuild.c
@@ -98,14 +98,14 @@ exists" when you try to open a db file. The API changed at release 4.3. */


#if defined(USE_DB) && defined(DB_VERSION_STRING)
void
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
+# if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
dbfn_bdb_error_callback(const DB_ENV *dbenv, const char *pfx, const char *msg)
{
dbenv = dbenv;
-#else
+# else
dbfn_bdb_error_callback(const char *pfx, char *msg)
{
-#endif
+# endif
pfx = pfx;
printf("Berkeley DB error: %s\n", msg);
}
@@ -212,14 +212,12 @@ if (argc != 3)
exit(1);
}

-if (Ustrcmp(argv[arg], "-") == 0) f = stdin; else
+if (Ustrcmp(argv[arg], "-") == 0)
+  f = stdin;
+else if (!(f = fopen(argv[arg], "rb")))
   {
-  f = fopen(argv[arg], "rb");
-  if (f == NULL)
-    {
-    printf("exim_dbmbuild: unable to open %s: %s\n", argv[arg], strerror(errno));
-    exit(1);
-    }
+  printf("exim_dbmbuild: unable to open %s: %s\n", argv[arg], strerror(errno));
+  exit(1);
   }


 /* By default Berkeley db does not put extensions on... which
diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index 5b0cffa..8972d10 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -1104,7 +1104,7 @@ NAME has the value "ldap". */
 while (strncmpic(url, US"ldap", 4) != 0)
   {
   const uschar *name = url;
-  while (*url != 0 && *url != '=') url++;
+  while (*url && *url != '=') url++;
   if (*url == '=')
     {
     int namelen;
@@ -1188,7 +1188,7 @@ result of ${quote_ldap_dn:...} quoting, which does apply URL quoting, because
 that is needed when the DN is used as a base DN in a query. Sigh. This is all
 far too complicated. */


-if (user != NULL)
+if (user)
   {
   uschar *t = user;
   for (uschar * s = user; *s != 0; s++)
@@ -1211,7 +1211,7 @@ if (user != NULL)
 DEBUG(D_lookup)
   debug_printf_indent("LDAP parameters: user=%s pass=%s size=%d time=%d connect=%d "
     "dereference=%d referrals=%s\n", user, password, sizelimit, timelimit,
-    tcplimit, dereference, (referrals == LDAP_OPT_ON)? "on" : "off");
+    tcplimit, dereference, referrals == LDAP_OPT_ON ? "on" : "off");


/* If the request is just to check authentication, some credentials must
be given. The password must not be empty because LDAP binds with an empty
@@ -1219,12 +1219,12 @@ password are considered anonymous, and will succeed on most installations. */

 if (search_type == SEARCH_LDAP_AUTH)
   {
-  if (user == NULL || password == NULL)
+  if (!user || !password)
     {
     *errmsg = US"ldapauth lookups must specify the username and password";
     return DEFER;
     }
-  if (password[0] == 0)
+  if (!*password)
     {
     DEBUG(D_lookup) debug_printf_indent("Empty password: ldapauth returns FAIL\n");
     return FAIL;
@@ -1245,22 +1245,20 @@ if (Ustrncmp(p, "://", 3) != 0)


/* No default servers, or URL contains a server name: just one attempt */

-if ((eldap_default_servers == NULL && local_servers == NULL) || p[3] != '/')
-  {
+if (!eldap_default_servers && !local_servers  || p[3] != '/')
   return perform_ldap_search(url, NULL, 0, search_type, res, errmsg,
     &defer_break, user, password, sizelimit, timelimit, tcplimit, dereference,
     referrals);
-  }


 /* Loop through the default servers until OK or FAIL. Use local_servers list
  * if defined in the lookup, otherwise use the global default list */
-list = (local_servers == NULL) ? eldap_default_servers : local_servers;
-while ((server = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
+list = !local_servers ? eldap_default_servers : local_servers;
+while ((server = string_nextinlist(&list, &sep, buffer, sizeof(buffer))))
   {
   int rc;
   int port = 0;
   uschar *colon = Ustrchr(server, ':');
-  if (colon != NULL)
+  if (colon)
     {
     *colon = 0;
     port = Uatoi(colon+1);
diff --git a/src/src/spool_in.c b/src/src/spool_in.c
index 8d5f5a7..575c398 100644
--- a/src/src/spool_in.c
+++ b/src/src/spool_in.c
@@ -386,21 +386,21 @@ and the number of warning messages for delivery delays that have been sent. */


if (Ufgets(big_buffer, big_buffer_size, fp) == NULL) goto SPOOL_READ_ERROR;

-{
-uschar *p = big_buffer + Ustrlen(big_buffer);
-while (p > big_buffer && isspace(p[-1])) p--;
-*p = 0;
-if (!isdigit(p[-1])) goto SPOOL_FORMAT_ERROR;
-while (p > big_buffer && (isdigit(p[-1]) || '-' == p[-1])) p--;
-gid = Uatoi(p);
-if (p <= big_buffer || *(--p) != ' ') goto SPOOL_FORMAT_ERROR;
-*p = 0;
-if (!isdigit(p[-1])) goto SPOOL_FORMAT_ERROR;
-while (p > big_buffer && (isdigit(p[-1]) || '-' == p[-1])) p--;
-uid = Uatoi(p);
-if (p <= big_buffer || *(--p) != ' ') goto SPOOL_FORMAT_ERROR;
-*p = 0;
-}
+ {
+ uschar *p = big_buffer + Ustrlen(big_buffer);
+ while (p > big_buffer && isspace(p[-1])) p--;
+ *p = 0;
+ if (!isdigit(p[-1])) goto SPOOL_FORMAT_ERROR;
+ while (p > big_buffer && (isdigit(p[-1]) || '-' == p[-1])) p--;
+ gid = Uatoi(p);
+ if (p <= big_buffer || *(--p) != ' ') goto SPOOL_FORMAT_ERROR;
+ *p = 0;
+ if (!isdigit(p[-1])) goto SPOOL_FORMAT_ERROR;
+ while (p > big_buffer && (isdigit(p[-1]) || '-' == p[-1])) p--;
+ uid = Uatoi(p);
+ if (p <= big_buffer || *(--p) != ' ') goto SPOOL_FORMAT_ERROR;
+ *p = 0;
+ }

originator_login = string_copy(big_buffer);
originator_uid = (uid_t)uid;