Fix for benchmark help broken in PR #5871

This commit is contained in:
David Garske
2023-01-11 15:05:07 -08:00
parent b2d8b1c2fd
commit 5e1c7c3db2

View File

@@ -8576,16 +8576,22 @@ void benchmark_configure(int block_size)
* str Algorithm string to print. * str Algorithm string to print.
* line Length of line used so far. * line Length of line used so far.
*/ */
#ifndef BENCH_MAX_LINE
#define BENCH_MAX_LINE 80
#endif
static void print_alg(const char* str, int* line) static void print_alg(const char* str, int* line)
{ {
int optLen; const char* const ident = " ";
if (*line == 0) {
optLen = (int)XSTRLEN(str) + 1; printf(ident);
if (optLen + *line > 80) { *line = (int)XSTRLEN(ident);
printf("\n "); }
*line = 13; printf(" %s", str);
*line += (int)XSTRLEN(str) + 1;
if (*line > BENCH_MAX_LINE) {
printf("\n");
*line = 0;
} }
*line += optLen;
} }
#endif /* WOLFSSL_BENCHMARK_ALL */ #endif /* WOLFSSL_BENCHMARK_ALL */
@@ -8645,37 +8651,26 @@ static void Usage(void)
e++; e++;
#ifndef WOLFSSL_BENCHMARK_ALL #ifndef WOLFSSL_BENCHMARK_ALL
printf("%s", bench_Usage_msg1[lng_index][e]); /* option -<alg> */ printf("%s", bench_Usage_msg1[lng_index][e]); /* option -<alg> */
printf(" "); line = 0;
line = 13;
for (i=0; bench_cipher_opt[i].str != NULL; i++) for (i=0; bench_cipher_opt[i].str != NULL; i++)
print_alg(bench_cipher_opt[i].str + 1, &line); print_alg(bench_cipher_opt[i].str, &line);
printf("\n ");
line = 13;
for (i=0; bench_digest_opt[i].str != NULL; i++) for (i=0; bench_digest_opt[i].str != NULL; i++)
print_alg(bench_digest_opt[i].str + 1, &line); print_alg(bench_digest_opt[i].str, &line);
printf("\n ");
line = 13;
for (i=0; bench_mac_opt[i].str != NULL; i++) for (i=0; bench_mac_opt[i].str != NULL; i++)
print_alg(bench_mac_opt[i].str + 1, &line); print_alg(bench_mac_opt[i].str, &line);
printf("\n ");
line = 13;
for (i=0; bench_asym_opt[i].str != NULL; i++) for (i=0; bench_asym_opt[i].str != NULL; i++)
print_alg(bench_asym_opt[i].str + 1, &line); print_alg(bench_asym_opt[i].str, &line);
printf("\n ");
line = 13;
for (i=0; bench_other_opt[i].str != NULL; i++) for (i=0; bench_other_opt[i].str != NULL; i++)
print_alg(bench_other_opt[i].str + 1, &line); print_alg(bench_other_opt[i].str, &line);
printf("\n ");
#if defined(HAVE_PQC) && defined(HAVE_LIBOQS) #if defined(HAVE_PQC) && defined(HAVE_LIBOQS)
line = 13;
for (i=0; bench_pq_asym_opt[i].str != NULL; i++) for (i=0; bench_pq_asym_opt[i].str != NULL; i++)
print_alg(bench_pq_asym_opt[i].str + 1, &line); print_alg(bench_pq_asym_opt[i].str, &line);
#if defined(HAVE_LIBOQS) #if defined(HAVE_LIBOQS)
for (i=0; bench_pq_asym_opt2[i].str != NULL; i++) for (i=0; bench_pq_asym_opt2[i].str != NULL; i++)
print_alg(bench_pq_asym_opt2[i].str + 1, &line); print_alg(bench_pq_asym_opt2[i].str, &line);
printf("\n");
#endif /* HAVE_LIBOQS */ #endif /* HAVE_LIBOQS */
#endif /* HAVE_PQC */ #endif /* HAVE_PQC */
printf("\n");
#endif /* !WOLFSSL_BENCHMARK_ALL */ #endif /* !WOLFSSL_BENCHMARK_ALL */
e++; e++;
printf("%s", bench_Usage_msg1[lng_index][e++]); /* option -lng */ printf("%s", bench_Usage_msg1[lng_index][e++]); /* option -lng */