]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Adding assert and using ZSTD_STRATEGY_MAX as ZSTD_NB_STRATEGIES
authorBimba Shrestha <bimbashrestha@fb.com>
Fri, 31 Jan 2020 01:54:01 +0000 (17:54 -0800)
committerBimba Shrestha <bimbashrestha@fb.com>
Fri, 31 Jan 2020 01:54:01 +0000 (17:54 -0800)
programs/zstdcli.c

index 40d1e621c28859b68d1e3edc4bcc6f3662ff6200..fed0a179f1f56cd9dee921c7e4debcf2ed8b5597 100644 (file)
@@ -544,7 +544,7 @@ static int init_cLevel(void) {
     return ZSTDCLI_CLEVEL_DEFAULT;
 }
 
-#define ZSTD_NB_STRATEGIES 9
+#define ZSTD_NB_STRATEGIES ZSTD_STRATEGY_MAX
 static const char* ZSTD_strategyMap[ZSTD_NB_STRATEGIES + 1] = { "", "ZSTD_fast",
                 "ZSTD_dfast", "ZSTD_greedy", "ZSTD_lazy", "ZSTD_lazy2", "ZSTD_btlazy2",
                 "ZSTD_btopt", "ZSTD_btultra", "ZSTD_btultra2"};
@@ -1240,6 +1240,7 @@ int main(int const argCount, const char* argv[])
                 DISPLAY(" - searchLog    : %u\n", cParams.searchLog);
                 DISPLAY(" - minMatch     : %u\n", cParams.minMatch);
                 DISPLAY(" - targetLength : %u\n", cParams.targetLength);
+                assert(cParams.strategy < ZSTD_NB_STRATEGIES + 1);
                 DISPLAY(" - strategy     : %s\n", ZSTD_strategyMap[(int)cParams.strategy]);
             }
         }