This checks that arguments are handled. If not, then this prints a short usage notice and returns an error. --- tests/checkasm/checkasm.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d72850f076..fafa4a0c82 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -756,6 +756,14 @@ static void bench_uninit(void) #endif } +static int usage(const char *path) +{ + fprintf(stderr, + "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n", + path); + return 1; +} + int main(int argc, char *argv[]) { unsigned int seed = av_get_random_seed(); @@ -771,25 +779,29 @@ int main(int argc, char *argv[]) return 0; } - while (argc > 1) { - if (!strncmp(argv[1], "--bench", 7)) { + for (i = 1; i < argc; i++) { + const char *arg = argv[i]; + unsigned long l; + char *end; + + if (!strncmp(arg, "--bench", 7)) { if (bench_init() < 0) return 1; - if (argv[1][7] == '=') { - state.bench_pattern = argv[1] + 8; + if (arg[7] == '=') { + state.bench_pattern = arg + 8; state.bench_pattern_len = strlen(state.bench_pattern); } else state.bench_pattern = ""; - } else if (!strncmp(argv[1], "--test=", 7)) { - state.test_name = argv[1] + 7; - } else if (!strcmp(argv[1], "--verbose") || !strcmp(argv[1], "-v")) { + } else if (!strncmp(arg, "--test=", 7)) { + state.test_name = arg + 7; + } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) { state.verbose = 1; + } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX && + *end == '\0') { + seed = l; } else { - seed = strtoul(argv[1], NULL, 10); + return usage(argv[0]); } - - argc--; - argv++; } fprintf(stderr, "checkasm: using random seed %u\n", seed); -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".