]> granicus.if.org Git - neomutt/commitdiff
check retval of REGCOMP()
authorRichard Russon <rich@flatcap.org>
Sun, 12 Nov 2017 23:58:17 +0000 (23:58 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 15 Nov 2017 15:12:11 +0000 (15:12 +0000)
`REGCOMP()` wraps `regcomp()` which returns int.

browser.c
curs_lib.c
init.c
mutt_regex.h
pattern.c

index f807a24d66b3abbc1b4bfa652260591a516f8841..5fc79d29a719f183c43dc209171a9709a6ee32ba 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -2003,7 +2003,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi
             }
 
             err = REGCOMP(&rx, s, REG_NOSUB);
-            if (err)
+            if (err != 0)
             {
               regerror(err, &rx, buf, sizeof(buf));
               regfree(&rx);
index 1f19f87ad9363c23da40541b87797300372516ea..43366aeed23c8962c409c988ce7bdbbb6df0a1b9 100644 (file)
@@ -266,10 +266,10 @@ int mutt_yesorno(const char *msg, int def)
 
   answer[1] = '\0';
 
-  reyes_ok = (expr = nl_langinfo(YESEXPR)) && expr[0] == '^' &&
-             !REGCOMP(&reyes, expr, REG_NOSUB);
-  reno_ok = (expr = nl_langinfo(NOEXPR)) && expr[0] == '^' &&
-            !REGCOMP(&reno, expr, REG_NOSUB);
+  reyes_ok = (expr = nl_langinfo(YESEXPR)) && (expr[0] == '^') &&
+             (REGCOMP(&reyes, expr, REG_NOSUB) == 0);
+  reno_ok = (expr = nl_langinfo(NOEXPR)) && (expr[0] == '^') &&
+            (REGCOMP(&reno, expr, REG_NOSUB) == 0);
 
   /*
    * In order to prevent the default answer to the question to wrapped
diff --git a/init.c b/init.c
index 9e22f933ac34fcde1e75ed201d62b9fb5e3c7db2..2698412989f4ddd9c750a5c77770087569c39fae 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1588,7 +1588,7 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s,
 
     FREE(&tmpminor);
 
-    if (ret)
+    if (ret != 0)
     {
       regerror(ret, &a->minor_regex, err->data, err->dsize);
       FREE(&a->major);
index 6ebe22deaf33be34181f0cd183e16c24cf3b146d..7e5117b714e3e630ac865db3afbd90ed8416ae38 100644 (file)
 #define REG_WORDS 0
 #endif
 
+/**
+ * REGCOMP - Compile a regular expression
+ * @param X regex_t struct to fill
+ * @param Y Regular expression string
+ * @param Z Flags
+ * @retval   0 Success
+ * @retval num Failure, e.g. REG_BADPAT
+ */
 #define REGCOMP(X, Y, Z) regcomp(X, Y, REG_WORDS | REG_EXTENDED | (Z))
+/**
+ * REGEXEC - Perform a regular expression comparison
+ * @param X regex_t containing compiled regular expression
+ * @param Y String to compare
+ * @retval 0           Success
+ * @retval REG_NOMATCH Failure
+ */
 #define REGEXEC(X, Y) regexec(&X, Y, (size_t) 0, (regmatch_t *) 0, (int) 0)
 
 /**
index 2a2aca5679e135a6ed8990c1d2c3e836d1a3005c..f70d9e59d17306eefebb6de4497b4285391dd715 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -114,7 +114,7 @@ static bool eat_regex(struct Pattern *pat, struct Buffer *s, struct Buffer *err)
     pat->p.regex = safe_malloc(sizeof(regex_t));
     r = REGCOMP(pat->p.regex, buf.data,
                 REG_NEWLINE | REG_NOSUB | mutt_which_case(buf.data));
-    if (r)
+    if (r != 0)
     {
       regerror(r, pat->p.regex, errmsg, sizeof(errmsg));
       mutt_buffer_printf(err, "'%s': %s", buf.data, errmsg);