]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: sample: Explicitly handle all possible enum values from mjson
authorTim Duesterhus <tim@bastelstu.be>
Thu, 15 Apr 2021 16:14:32 +0000 (18:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Apr 2021 18:33:34 +0000 (20:33 +0200)
This makes it easier to find bugs, because -Wswitch can help us.

src/sample.c

index c2d9beda322472c8990311cd9959ba9ed0a1801c..89c443757b9e18758525f35245aba1a280f5c0c4 100644 (file)
@@ -3774,8 +3774,19 @@ static int sample_conv_json_query(const struct arg *args, struct sample *smp, vo
                        }
                        break;
                }
-               default:
-                       /* no valid token found */
+               case MJSON_TOK_NULL:
+               case MJSON_TOK_ARRAY:
+               case MJSON_TOK_OBJECT:
+                       /* We cannot handle these. */
+                       return 0;
+               case MJSON_TOK_INVALID:
+                       /* Nothing matches the query. */
+                       return 0;
+               case MJSON_TOK_KEY:
+                       /* This is not a valid return value according to the
+                        * mjson documentation, but we handle it to benefit
+                        * from '-Wswitch'.
+                        */
                        return 0;
        }
        return 1;