]> diplodocus.org Git - nmh/commitdiff
Deference char pointer to test for empty string instead of strlen(3).
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 17 Oct 2016 00:34:18 +0000 (01:34 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 17 Oct 2016 00:34:18 +0000 (01:34 +0100)
sbr/readconfig.c
uip/anno.c
uip/mhlogin.c
uip/mhlsbr.c
uip/sendsbr.c

index 7098402..1588b53 100644 (file)
@@ -138,7 +138,7 @@ readconfig (struct node **npp, FILE *ib, const char *file, int ctx)
        for (np = m_defs; np; np = np->n_next) {
            /* Yes, this is O(N^2).  The profile should be small enough so
               that's not a performance problem. */
        for (np = m_defs; np; np = np->n_next) {
            /* Yes, this is O(N^2).  The profile should be small enough so
               that's not a performance problem. */
-           if (strlen (np->n_name) > 0  &&  strcmp ("#", np->n_name)) {
+           if (*np->n_name && strcmp("#", np->n_name)) {
                struct node *np2;
                for (np2 = np->n_next; np2; np2 = np2->n_next) {
                    if (! strcasecmp (np->n_name, np2->n_name)) {
                struct node *np2;
                for (np2 = np->n_next; np2; np2 = np2->n_next) {
                    if (! strcasecmp (np->n_name, np2->n_name)) {
index 7a91f25..d815320 100644 (file)
@@ -283,7 +283,7 @@ make_comp (char **ap)
 
     if ((cp = *ap + strlen (*ap) - 1) > *ap && *cp == ':')
        *cp = 0;
 
     if ((cp = *ap + strlen (*ap) - 1) > *ap && *cp == ':')
        *cp = 0;
-    if (strlen (*ap) == 0)
+    if (!**ap)
        adios (NULL, "null component name");
     if (**ap == '-')
        adios (NULL, "invalid component name %s", *ap);
        adios (NULL, "null component name");
     if (**ap == '-')
        adios (NULL, "invalid component name %s", *ap);
index aabe9a3..56b1e36 100644 (file)
@@ -101,10 +101,10 @@ do_login(const char *svc, const char *user, const char *browser, int snoop)
     fflush(stdout);
     code = geta();
 
     fflush(stdout);
     code = geta();
 
-    while (strlen(code) == 0 ||
+    while (!*code || ||
            ((cred = mh_oauth_authorize(code, ctx)) == NULL
             && mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT)) {
            ((cred = mh_oauth_authorize(code, ctx)) == NULL
             && mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT)) {
-      printf(strlen(code) == 0  ?  "Empty code; try again? "  :  "Code rejected; try again? ");
+      printf(!*code  ?  "Empty code; try again? "  :  "Code rejected; try again? ");
       fflush(stdout);
       code = geta();
     }
       fflush(stdout);
       code = geta();
     }
index bd354a3..ee045ea 100644 (file)
@@ -1214,7 +1214,7 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2)
 
        fmt_scan (c1->c_fmt, scanl, BUFSIZ - 1, dat, NULL);
        buffer = charstring_buffer_copy (scanl);
 
        fmt_scan (c1->c_fmt, scanl, BUFSIZ - 1, dat, NULL);
        buffer = charstring_buffer_copy (scanl);
-       if (strlen (buffer) > 0) {
+       if (*buffer) {
            if (c2->c_text)
                c2->c_text = add (",\n", c2->c_text);
            if (*(cp = buffer + strlen (buffer) - 1) == '\n')
            if (c2->c_text)
                c2->c_text = add (",\n", c2->c_text);
            if (*(cp = buffer + strlen (buffer) - 1) == '\n')
index 44f56bf..2ba52b1 100644 (file)
@@ -867,7 +867,7 @@ get_from_header_info(const char *filename, const char **addr, const char **host,
         char *hostformat = "%(host{Envelope-From})";
 
         if ((*addr = get_message_header_info (in, addrformat)) == NULL  ||
         char *hostformat = "%(host{Envelope-From})";
 
         if ((*addr = get_message_header_info (in, addrformat)) == NULL  ||
-            strlen (*addr) == 0) {
+            !**addr) {
             addrformat = distfile == NULL  ?  "%(addr{Sender})"  :  "%(addr{Resent-Sender})";
             hostformat = distfile == NULL  ?  "%(host{Sender})"  :  "%(host{Resent-Sender})";
 
             addrformat = distfile == NULL  ?  "%(addr{Sender})"  :  "%(addr{Resent-Sender})";
             hostformat = distfile == NULL  ?  "%(host{Sender})"  :  "%(host{Resent-Sender})";
 
@@ -963,12 +963,11 @@ get_message_header_info(FILE *in, char *format) {
     /* Trim trailing newline, if any. */
     retval = rtrim(charstring_buffer_copy((buffer)));
     charstring_free(buffer);
     /* Trim trailing newline, if any. */
     retval = rtrim(charstring_buffer_copy((buffer)));
     charstring_free(buffer);
-    if (strlen (retval) > 0) {
+    if (*retval)
         return retval;
         return retval;
-    } else {
-        free (retval);
-        return NULL;
-    }
+
+    free(retval);
+    return NULL;
 }
 
 
 }
 
 
@@ -998,7 +997,7 @@ merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp)
     }
 
     /* Use argsplit() to do the real work of splitting the args in the profile entry. */
     }
 
     /* Use argsplit() to do the real work of splitting the args in the profile entry. */
-    if (profile_entry  &&  strlen(profile_entry) > 0) {
+    if (profile_entry && *profile_entry) {
         int profile_vecp;
         char *file;
         char **profile_vec = argsplit(profile_entry, &file, &profile_vecp);
         int profile_vecp;
         char *file;
         char **profile_vec = argsplit(profile_entry, &file, &profile_vecp);