From: Tim Duesterhus Date: Thu, 15 Apr 2021 16:14:32 +0000 (+0200) Subject: CLEANUP: sample: Explicitly handle all possible enum values from mjson X-Git-Tag: v2.4-dev17~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8f3bc8ffcad8dfd6a58722b04026771943b463d3;p=thirdparty%2Fhaproxy.git CLEANUP: sample: Explicitly handle all possible enum values from mjson This makes it easier to find bugs, because -Wswitch can help us. --- diff --git a/src/sample.c b/src/sample.c index c2d9beda32..89c443757b 100644 --- a/src/sample.c +++ b/src/sample.c @@ -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;