summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-06-27 15:35:12 -0700
committerKevin McCarthy <kevin@8t8.us>2019-06-28 12:44:02 -0700
commit8768e10f85337400d952890c70ca3468c09507ec (patch)
treed25d51d8a47eb892b60e6116baa265f7697383ca
parent4c728278f5ceb6b9ecf6cec7cf637475e77b4089 (diff)
Remove unnecessary "" checks for DT_STR and DT_PATH MuttVars.
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.
-rw-r--r--alias.c2
-rw-r--r--bcache.c2
-rw-r--r--charset.c2
-rw-r--r--commands.c4
-rw-r--r--compose.c3
-rw-r--r--crypt-gpgme.c8
-rw-r--r--crypt.c4
-rw-r--r--curs_main.c2
-rw-r--r--handler.c2
-rw-r--r--hcache.c3
-rw-r--r--hook.c2
-rw-r--r--imap/auth.c2
-rw-r--r--imap/auth_oauth.c2
-rw-r--r--init.c2
-rw-r--r--mutt_socket.c2
-rw-r--r--muttlib.c2
-rw-r--r--parse.c4
-rw-r--r--pgpinvoke.c4
-rw-r--r--pop_auth.c4
-rw-r--r--rfc1524.c2
-rw-r--r--rfc2047.c6
-rw-r--r--rfc2231.c2
-rw-r--r--send.c6
-rw-r--r--sendlib.c14
-rw-r--r--smime.c6
-rw-r--r--smtp.c2
26 files changed, 45 insertions, 49 deletions
diff --git a/alias.c b/alias.c
index 593d5d99..c3051bf9 100644
--- a/alias.c
+++ b/alias.c
@@ -215,7 +215,7 @@ static void recode_buf (char *buf, size_t buflen)
{
char *s;
- if (!ConfigCharset || !*ConfigCharset || !Charset)
+ if (!ConfigCharset || !Charset)
return;
s = safe_strdup (buf);
if (!s)
diff --git a/bcache.c b/bcache.c
index 62838fd4..5530d0cf 100644
--- a/bcache.c
+++ b/bcache.c
@@ -46,7 +46,7 @@ static int bcache_path(ACCOUNT *account, const char *mailbox,
ciss_url_t url;
int len;
- if (!account || !MessageCachedir || !*MessageCachedir || !dst || !dstlen)
+ if (!account || !MessageCachedir || !dst || !dstlen)
return -1;
/* make up a ciss_url_t we can turn into a string */
diff --git a/charset.c b/charset.c
index 759c2052..7afaeb8b 100644
--- a/charset.c
+++ b/charset.c
@@ -317,7 +317,7 @@ char *mutt_get_default_charset ()
const char *c = AssumedCharset;
const char *c1;
- if (c && *c)
+ if (c)
{
c1 = strchr (c, ':');
strfcpy (fcharset, c, c1 ? (c1 - c + 1) : sizeof (fcharset));
diff --git a/commands.c b/commands.c
index 15f6dbbc..ac8a120b 100644
--- a/commands.c
+++ b/commands.c
@@ -194,7 +194,7 @@ int mutt_display_message (HEADER *cur)
return (0);
}
- if (DisplayFilter && *DisplayFilter)
+ if (DisplayFilter)
{
fpfilterout = fpout;
fpout = NULL;
@@ -585,7 +585,7 @@ void mutt_pipe_message (HEADER *h)
void mutt_print_message (HEADER *h)
{
- if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd))
+ if (quadoption (OPT_PRINT) && !PrintCmd)
{
mutt_message (_("No printing command has been defined."));
return;
diff --git a/compose.c b/compose.c
index 05ad4d47..4d1b7135 100644
--- a/compose.c
+++ b/compose.c
@@ -260,8 +260,7 @@ static void redraw_crypt_lines (HEADER *msg)
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME)
&& (msg->security & ENCRYPT)
- && SmimeCryptAlg
- && *SmimeCryptAlg)
+ && SmimeCryptAlg)
{
SETCOLOR (MT_COLOR_COMPOSE_HEADER);
mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPTINFO, 40, "%s", _("Encrypt with: "));
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 696daa62..bbdede5f 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -943,11 +943,11 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime)
char *fpr, *fpr2;
if (for_smime)
- signid = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
+ signid = SmimeSignAs ? SmimeSignAs : SmimeDefaultKey;
else
- signid = (PgpSignAs && *PgpSignAs) ? PgpSignAs : PgpDefaultKey;
+ signid = PgpSignAs ? PgpSignAs : PgpDefaultKey;
- if (!signid || !*signid)
+ if (!signid)
return 0;
listctx = create_gpgme_context (for_smime);
@@ -2319,7 +2319,7 @@ static int pgp_gpgme_extract_keys (gpgme_data_t keydata, FILE** fp)
if (legacy_api)
{
- snprintf (tmpdir, sizeof(tmpdir), "%s/mutt-gpgme-XXXXXX", Tempdir);
+ snprintf (tmpdir, sizeof(tmpdir), "%s/mutt-gpgme-XXXXXX", NONULL (Tempdir));
if (!mkdtemp (tmpdir))
{
dprint (1, (debugfile, "Error creating temporary GPGME home\n"));
diff --git a/crypt.c b/crypt.c
index 98998280..85ab5fdf 100644
--- a/crypt.c
+++ b/crypt.c
@@ -860,7 +860,7 @@ int crypt_get_keys (HEADER *msg, char **keylist, int oppenc_mode)
}
}
- if (!oppenc_mode && self_encrypt && *self_encrypt)
+ if (!oppenc_mode && self_encrypt)
{
keylist_size = mutt_strlen (*keylist);
safe_realloc (keylist, keylist_size + mutt_strlen (self_encrypt) + 2);
@@ -926,7 +926,7 @@ int mutt_should_hide_protected_subject (HEADER *h)
if (option (OPTCRYPTPROTHDRSWRITE) &&
(h->security & ENCRYPT) &&
!(h->security & INLINE) &&
- ProtHdrSubject && *ProtHdrSubject)
+ ProtHdrSubject)
return 1;
return 0;
diff --git a/curs_main.c b/curs_main.c
index 32925f29..2054f42d 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -2360,7 +2360,7 @@ int mutt_index_menu (void)
if (!mutt_get_field (_("Enter macro stroke: "), buf, sizeof(buf),
MUTT_CLEAR) && buf[0])
{
- snprintf(str, sizeof(str), "%s%s", MarkMacroPrefix, buf);
+ snprintf(str, sizeof(str), "%s%s", NONULL (MarkMacroPrefix), buf);
snprintf(macro, sizeof(macro),
"<search>~i \"%s\"\n", CURHDR->env->message_id);
/* L10N: "message hotkey" is the key bindings menu description of a
diff --git a/handler.c b/handler.c
index 36a855b3..5c6397fc 100644
--- a/handler.c
+++ b/handler.c
@@ -1546,7 +1546,7 @@ void mutt_decode_attachment (BODY *b, STATE *s)
if (istext && s->flags & MUTT_CHARCONV)
{
char *charset = mutt_get_parameter ("charset", b->parameter);
- if (!charset && AssumedCharset && *AssumedCharset)
+ if (!charset && AssumedCharset)
charset = mutt_get_default_charset ();
if (charset && Charset)
cd = mutt_iconv_open (Charset, charset, MUTT_ICONV_HOOK_FROM);
diff --git a/hcache.c b/hcache.c
index 2f601102..466bb4d1 100644
--- a/hcache.c
+++ b/hcache.c
@@ -609,8 +609,7 @@ mutt_hcache_per_folder(const char *path, const char *folder,
char* s;
int ret, plen;
#ifndef HAVE_ICONV
- const char *chs = Charset && *Charset ? Charset :
- mutt_get_default_charset ();
+ const char *chs = Charset ? Charset : mutt_get_default_charset ();
#endif
plen = mutt_strlen (path);
diff --git a/hook.c b/hook.c
index 3b339d8d..1c96684a 100644
--- a/hook.c
+++ b/hook.c
@@ -334,7 +334,7 @@ int mutt_parse_idxfmt_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata,
goto out;
}
- if (DefaultHook && *DefaultHook)
+ if (DefaultHook)
mutt_check_simple (pattern, DefaultHook);
/* check to make sure that a matching hook doesn't already exist */
diff --git a/imap/auth.c b/imap/auth.c
index 38512be7..e32b5ab4 100644
--- a/imap/auth.c
+++ b/imap/auth.c
@@ -57,7 +57,7 @@ int imap_authenticate (IMAP_DATA* idata)
char* delim;
int r = -1;
- if (ImapAuthenticators && *ImapAuthenticators)
+ if (ImapAuthenticators)
{
/* Try user-specified list of authentication methods */
methods = safe_strdup (ImapAuthenticators);
diff --git a/imap/auth_oauth.c b/imap/auth_oauth.c
index 8c7ab9d0..a301e166 100644
--- a/imap/auth_oauth.c
+++ b/imap/auth_oauth.c
@@ -42,7 +42,7 @@ imap_auth_res_t imap_auth_oauth (IMAP_DATA* idata, const char* method)
return IMAP_AUTH_UNAVAIL;
/* If they did not explicitly request or configure oauth then fail quietly */
- if (!(method || (ImapOauthRefreshCmd && *ImapOauthRefreshCmd)))
+ if (!(method || ImapOauthRefreshCmd))
return IMAP_AUTH_UNAVAIL;
mutt_message _("Authenticating (OAUTHBEARER)...");
diff --git a/init.c b/init.c
index 1a2b933a..e02f1201 100644
--- a/init.c
+++ b/init.c
@@ -2719,7 +2719,7 @@ static int source_rc (const char *rcfile, BUFFER *err)
mutt_buffer_init (&token);
while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line, MUTT_CONT)) != NULL)
{
- conv=ConfigCharset && (*ConfigCharset) && Charset;
+ conv=ConfigCharset && Charset;
if (conv)
{
currentline=safe_strdup(linebuf);
diff --git a/mutt_socket.c b/mutt_socket.c
index 9c22f35f..fbb0e5c4 100644
--- a/mutt_socket.c
+++ b/mutt_socket.c
@@ -265,7 +265,7 @@ CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account)
conn->next = Connections;
Connections = conn;
- if (Tunnel && *Tunnel)
+ if (Tunnel)
mutt_tunnel_socket_setup (conn);
else if (account->flags & MUTT_ACCT_SSL)
{
diff --git a/muttlib.c b/muttlib.c
index 39b9e8d5..4350136d 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -496,7 +496,7 @@ void _mutt_buffer_expand_path (BUFFER *src, int rx)
mutt_buffer_strcpy (p, NONULL (Maildir));
else
#endif
- if (Maildir && *Maildir && Maildir[strlen (Maildir) - 1] == '/')
+ if (Maildir && Maildir[strlen (Maildir) - 1] == '/')
mutt_buffer_strcpy (p, NONULL (Maildir));
else
mutt_buffer_printf (p, "%s/", NONULL (Maildir));
diff --git a/parse.c b/parse.c
index 8f307aed..6646fd03 100644
--- a/parse.c
+++ b/parse.c
@@ -183,7 +183,7 @@ static PARAMETER *parse_parameters (const char *s)
s++;
for (i=0; *s && i < sizeof (buffer) - 1; i++, s++)
{
- if (AssumedCharset && *AssumedCharset)
+ if (AssumedCharset)
{
/* As iso-2022-* has a character of '"' with non-ascii state,
* ignore it. */
@@ -371,7 +371,7 @@ void mutt_parse_content_type (char *s, BODY *ct)
if (ct->type == TYPETEXT)
{
if (!(pc = mutt_get_parameter ("charset", ct->parameter)))
- mutt_set_parameter ("charset", (AssumedCharset && *AssumedCharset) ?
+ mutt_set_parameter ("charset", AssumedCharset ?
(const char *) mutt_get_default_charset ()
: "us-ascii", &ct->parameter);
}
diff --git a/pgpinvoke.c b/pgpinvoke.c
index c1ae7e39..d9a73d02 100644
--- a/pgpinvoke.c
+++ b/pgpinvoke.c
@@ -178,7 +178,7 @@ static pid_t pgp_invoke (FILE **pgpin, FILE **pgpout, FILE **pgperr,
cctx.need_passphrase = need_passphrase;
cctx.fname = fname;
cctx.sig_fname = sig_fname;
- if (PgpSignAs && *PgpSignAs)
+ if (PgpSignAs)
cctx.signas = PgpSignAs;
else
cctx.signas = PgpDefaultKey;
@@ -273,7 +273,7 @@ void pgp_invoke_import (const char *fname)
mutt_buffer_quote_filename (fnamebuf, fname);
cctx.fname = mutt_b2s (fnamebuf);
- if (PgpSignAs && *PgpSignAs)
+ if (PgpSignAs)
cctx.signas = PgpSignAs;
else
cctx.signas = PgpDefaultKey;
diff --git a/pop_auth.c b/pop_auth.c
index 1c3e1c1b..fd866ae0 100644
--- a/pop_auth.c
+++ b/pop_auth.c
@@ -328,7 +328,7 @@ static pop_auth_res_t pop_auth_oauth (POP_DATA *pop_data, const char *method)
int ret, len;
/* If they did not explicitly request or configure oauth then fail quietly */
- if (!(method || (PopOauthRefreshCmd && *PopOauthRefreshCmd)))
+ if (!(method || PopOauthRefreshCmd))
return POP_A_UNAVAIL;
mutt_message _("Authenticating (OAUTHBEARER)...");
@@ -406,7 +406,7 @@ int pop_authenticate (POP_DATA* pop_data)
if (mutt_account_getuser (acct) || !acct->user[0])
return -3;
- if (PopAuthenticators && *PopAuthenticators)
+ if (PopAuthenticators)
{
/* Try user-specified list of authentication methods */
methods = safe_strdup (PopAuthenticators);
diff --git a/rfc1524.c b/rfc1524.c
index 50ff8469..228c5671 100644
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -433,7 +433,7 @@ int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt)
* and overridden by the MAILCAPS environment variable, and, just to be nice,
* we'll make it specifiable in .muttrc
*/
- if (!curr || !*curr)
+ if (!curr)
{
mutt_error _("No mailcap path specified");
return 0;
diff --git a/rfc2047.c b/rfc2047.c
index f2f333d3..7ed08c50 100644
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -593,7 +593,7 @@ void _rfc2047_encode_string (char **pd, int encode_specials, int col)
return;
charsets = SendCharset;
- if (!charsets || !*charsets)
+ if (!charsets)
charsets = "utf-8";
rfc2047_encode (*pd, strlen (*pd), col,
@@ -810,7 +810,7 @@ static void convert_and_add_text (BUFFER *d, const char *text, size_t len)
{
char *t;
- if (AssumedCharset && *AssumedCharset)
+ if (AssumedCharset)
{
t = safe_malloc (len + 1);
strfcpy (t, text, len + 1);
@@ -950,7 +950,7 @@ void rfc2047_decode_adrlist (ADDRESS *a)
while (a)
{
if (a->personal && ((strstr (a->personal, "=?") != NULL) ||
- (AssumedCharset && *AssumedCharset)))
+ AssumedCharset))
rfc2047_decode (&a->personal);
else if (a->group && a->mailbox && (strstr (a->mailbox, "=?") != NULL))
rfc2047_decode (&a->mailbox);
diff --git a/rfc2231.c b/rfc2231.c
index e3d8e1a5..68d051ca 100644
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -116,7 +116,7 @@ void rfc2231_decode_parameters (PARAMETER **headp)
if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?"))
rfc2047_decode (&p->value);
- else if (AssumedCharset && *AssumedCharset)
+ else if (AssumedCharset)
convert_nonmime_string (&p->value);
*last = p;
diff --git a/send.c b/send.c
index 2471d242..d45141c3 100644
--- a/send.c
+++ b/send.c
@@ -1455,7 +1455,7 @@ static int postpone_message (HEADER *msg, HEADER *cur, char *fcc, int flags)
int is_signed;
BODY *clear_content = NULL;
- if (!(Postponed && *Postponed))
+ if (!Postponed)
{
mutt_error _("Cannot postpone. $postponed is unset");
return -1;
@@ -1472,10 +1472,10 @@ static int postpone_message (HEADER *msg, HEADER *cur, char *fcc, int flags)
encrypt_as = PgpDefaultKey;
else if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
encrypt_as = SmimeDefaultKey;
- if (!(encrypt_as && *encrypt_as))
+ if (!encrypt_as)
encrypt_as = PostponeEncryptAs;
- if (encrypt_as && *encrypt_as)
+ if (encrypt_as)
{
is_signed = msg->security & SIGN;
if (is_signed)
diff --git a/sendlib.c b/sendlib.c
index 46212a2f..331cc2b2 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -915,8 +915,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
{
char *chs = mutt_get_parameter ("charset", b->parameter);
- char *fchs = b->use_disp ? ((AttachCharset && *AttachCharset) ?
- AttachCharset : Charset) : Charset;
+ char *fchs = b->use_disp ? (AttachCharset ? AttachCharset : Charset) : Charset;
if (Charset && (chs || SendCharset) &&
convert_file_from_to (fp, fchs, chs ? chs : SendCharset,
&fromcode, &tocode, info) != (size_t)(-1))
@@ -1407,8 +1406,7 @@ BODY *mutt_make_file_attach (const char *path)
att = mutt_new_body ();
att->filename = safe_strdup (path);
- if (MimeTypeQueryCmd && *MimeTypeQueryCmd &&
- option (OPTMIMETYPEQUERYFIRST))
+ if (MimeTypeQueryCmd && option (OPTMIMETYPEQUERYFIRST))
run_mime_type_query (att);
/* Attempt to determine the appropriate content-type based on the filename
@@ -1418,7 +1416,7 @@ BODY *mutt_make_file_attach (const char *path)
mutt_lookup_mime_type (att, path);
if (!att->subtype &&
- MimeTypeQueryCmd && *MimeTypeQueryCmd &&
+ MimeTypeQueryCmd &&
!option (OPTMIMETYPEQUERYFIRST))
run_mime_type_query (att);
@@ -2856,7 +2854,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
if (hdr->security & SIGN)
{
fputc ('S', msg->fp);
- if (PgpSignAs && *PgpSignAs)
+ if (PgpSignAs)
fprintf (msg->fp, "<%s>", PgpSignAs);
}
if (hdr->security & INLINE)
@@ -2872,7 +2870,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
if (hdr->security & ENCRYPT)
{
fputc ('E', msg->fp);
- if (SmimeCryptAlg && *SmimeCryptAlg)
+ if (SmimeCryptAlg)
fprintf (msg->fp, "C<%s>", SmimeCryptAlg);
}
if (hdr->security & OPPENCRYPT)
@@ -2880,7 +2878,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
if (hdr->security & SIGN)
{
fputc ('S', msg->fp);
- if (SmimeSignAs && *SmimeSignAs)
+ if (SmimeSignAs)
fprintf (msg->fp, "<%s>", SmimeSignAs);
}
if (hdr->security & INLINE)
diff --git a/smime.c b/smime.c
index c52f68f8..a8909121 100644
--- a/smime.c
+++ b/smime.c
@@ -859,7 +859,7 @@ void smime_getkeys (ENVELOPE *env)
ADDRESS *t;
int found = 0;
- if (option (OPTSDEFAULTDECRYPTKEY) && SmimeDefaultKey && *SmimeDefaultKey)
+ if (option (OPTSDEFAULTDECRYPTKEY) && SmimeDefaultKey)
{
snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
NONULL (SmimeKeys), SmimeDefaultKey);
@@ -1545,8 +1545,8 @@ BODY *smime_sign_message (BODY *a )
char *intermediates;
char *micalg;
- signas = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
- if (!signas || !*signas)
+ signas = SmimeSignAs ? SmimeSignAs : SmimeDefaultKey;
+ if (!signas)
{
mutt_error _("Can't sign: No key specified. Use Sign As.");
return NULL;
diff --git a/smtp.c b/smtp.c
index 16223d31..1e80d5e6 100644
--- a/smtp.c
+++ b/smtp.c
@@ -508,7 +508,7 @@ static int smtp_auth (CONNECTION* conn)
{
int r = SMTP_AUTH_UNAVAIL;
- if (SmtpAuthenticators && *SmtpAuthenticators)
+ if (SmtpAuthenticators)
{
char* methods = safe_strdup (SmtpAuthenticators);
char* method;