]> granicus.if.org Git - neomutt/commitdiff
Remove unnecessary checks for strings
authorKevin McCarthy <kevin@8t8.us>
Thu, 27 Jun 2019 22:35:12 +0000 (15:35 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 15 Jul 2019 21:35:05 +0000 (22:35 +0100)
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 <rich@flatcap.org>
email/rfc2047.c
mutt/charset.c
ncrypt/crypt.c
send.c

index bb98b13dae74d56cca19e3074c5a3c0cf5360c1f..e337dde484572105a8f71fd7193877ae5f17847b 100644 (file)
@@ -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;
index 45215d82b2120fed4ae152d1aeba090f1d9175b3..d1e5a328e778222346beae08dfa32667e44a2a6b 100644 (file)
@@ -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));
index ee95419f04ab4faa238dcfd6b44f07ebc712313c..54fb77c74866efb70d1b1ccda0189c01d3bfd0c9 100644 (file)
@@ -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 8b784db5898849253bcaaba651fa93402908ba6e..a148f8d52e805715cb7cc32096c30c2434eee719 100644 (file)
--- 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)