From: Kevin McCarthy Date: Thu, 27 Jun 2019 22:35:12 +0000 (-0700) Subject: Remove unnecessary checks for strings X-Git-Tag: 2019-10-25~132^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1e834bb46f7b79f57a45383d0d527b0053c8d01;p=neomutt Remove unnecessary checks for strings MuttVars of those types are set via safe_strdup(), which returns NULL if the original is "". Thus Var implies *Var. A good portion of the code relies on that axiom, but over the years some (Var && *Var) checks have crept in, including from me. This was partially because of the INITVAL("") that were in the code, which implied (incorrectly) the initial value could be "". Commit 2f91d43e removed those to make it more clear. This commit removes the *Var checks to make it even clearer, and help avoid them creeping back in again. Co-authored-by: Richard Russon --- diff --git a/email/rfc2047.c b/email/rfc2047.c index bb98b13da..e337dde48 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -627,7 +627,7 @@ void rfc2047_encode(char **pd, const char *specials, int col, const char *charse if (!C_Charset || !pd || !*pd) return; - if (!charsets || !*charsets) + if (!charsets) charsets = "utf-8"; char *e = NULL; diff --git a/mutt/charset.c b/mutt/charset.c index 45215d82b..d1e5a328e 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -407,7 +407,7 @@ char *mutt_ch_get_default_charset(void) const char *c = C_AssumedCharset; const char *c1 = NULL; - if (c && *c) + if (c) { c1 = strchr(c, ':'); mutt_str_strfcpy(fcharset, c, c1 ? (c1 - c + 1) : sizeof(fcharset)); diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index ee95419f0..54fb77c74 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -963,7 +963,7 @@ int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode) } } - if (!oppenc_mode && self_encrypt && *self_encrypt) + if (!oppenc_mode && self_encrypt) { const size_t keylist_size = mutt_str_strlen(*keylist); mutt_mem_realloc(keylist, keylist_size + mutt_str_strlen(self_encrypt) + 2); diff --git a/send.c b/send.c index 8b784db58..a148f8d52 100644 --- a/send.c +++ b/send.c @@ -1755,10 +1755,10 @@ static int postpone_message(struct Email *e_post, struct Email *e_cur, char *fcc encrypt_as = C_PgpDefaultKey; else if (((WithCrypto & APPLICATION_SMIME) != 0) && (e_post->security & APPLICATION_SMIME)) encrypt_as = C_SmimeDefaultKey; - if (!(encrypt_as && *encrypt_as)) + if (!encrypt_as) encrypt_as = C_PostponeEncryptAs; - if (encrypt_as && *encrypt_as) + if (encrypt_as) { bool is_signed = (e_post->security & SEC_SIGN); if (is_signed)