bench: fail early if user inputs invalid value for SECP256K1_BENCH_ITERS

In this change the get_iters function was updated to print an error
message and then return 0. In the functions that use get_iters they
print the help text and then EXIT_FAILURE
This commit is contained in:
kevkevinpal
2026-01-08 12:15:33 -05:00
parent 4721e077b4
commit c09215f7af
4 changed files with 23 additions and 4 deletions

View File

@@ -177,8 +177,6 @@ int main(int argc, char** argv) {
bench_data data;
int d = argc == 1;
int default_iters = 20000;
int iters = get_iters(default_iters);
/* Check for invalid user arguments */
char* valid_args[] = {"ecdsa", "verify", "ecdsa_verify", "sign", "ecdsa_sign", "ecdh", "recover",
@@ -188,6 +186,13 @@ int main(int argc, char** argv) {
size_t valid_args_size = sizeof(valid_args)/sizeof(valid_args[0]);
int invalid_args = have_invalid_args(argc, argv, valid_args, valid_args_size);
int default_iters = 20000;
int iters = get_iters(default_iters);
if (iters == 0) {
help(default_iters);
return EXIT_FAILURE;
}
if (argc > 1) {
if (have_flag(argc, argv, "-h")
|| have_flag(argc, argv, "--help")