From: Ralph Corderoy Date: Mon, 17 Oct 2016 00:34:18 +0000 (+0100) Subject: Deference char pointer to test for empty string instead of strlen(3). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/fc31cece?ds=inline;hp=b9dda34301de552ad6413e4dd022114fd5219cc9 Deference char pointer to test for empty string instead of strlen(3). --- diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 70984022..1588b539 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -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. */ - 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)) { diff --git a/uip/anno.c b/uip/anno.c index 7a91f251..d815320b 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -283,7 +283,7 @@ make_comp (char **ap) 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); diff --git a/uip/mhlogin.c b/uip/mhlogin.c index aabe9a3d..56b1e36f 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -101,10 +101,10 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) 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)) { - 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(); } diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index bd354a31..ee045ea0 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -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); - 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') diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 44f56bf4..2ba52b1e 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -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 || - strlen (*addr) == 0) { + !**addr) { 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); - if (strlen (retval) > 0) { + if (*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. */ - 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);