]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cache: Don't needlessly test "cache" keyword in parse_cache_flt()
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 May 2020 09:58:16 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 May 2020 15:47:18 +0000 (17:47 +0200)
parse_cache_flt() is the registered callback for the "cache" filter keyword. It
is only called when the "cache" keyword is found on a filter line. So, it is
useless to test the filter name in the callback function.

This patch should fix the issue #634. It may be backported as far as 1.9.

src/cache.c

index 3b248ef465c207f48fb912d6543fd1b2ee0e0a7b..ed50b29b66c9ebe18436243a84bf0b7c5be225df 100644 (file)
@@ -1411,19 +1411,17 @@ parse_cache_flt(char **args, int *cur_arg, struct proxy *px,
        char *name = NULL;
        int pos = *cur_arg;
 
-       /* Get the cache filter name*/
-       if (!strcmp(args[pos], "cache")) {
-               if (!*args[pos + 1]) {
-                       memprintf(err, "%s : expects an <id> argument", args[pos]);
-                       goto error;
-               }
-               name = strdup(args[pos + 1]);
-               if (!name) {
-                       memprintf(err, "%s '%s' : out of memory", args[pos], args[pos + 1]);
-                       goto error;
-               }
-               pos += 2;
+       /* Get the cache filter name. <pos> point on "cache" keyword */
+       if (!*args[pos + 1]) {
+               memprintf(err, "%s : expects an <id> argument", args[pos]);
+               goto error;
+       }
+       name = strdup(args[pos + 1]);
+       if (!name) {
+               memprintf(err, "%s '%s' : out of memory", args[pos], args[pos + 1]);
+               goto error;
        }
+       pos += 2;
 
        /* Check if an implicit filter with the same name already exists. If so,
         * we remove the implicit filter to use the explicit one. */