From 2085624a29370e6834000c7d578d88530039ce8f Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 14 Jan 2022 17:11:55 -0800 Subject: [PATCH] Old Compiler Warning Cleanup (GCC 4.0.2) 1. Removed pragma disabling the warning for non-literal format strings on `printf()`. 2. Switched the `printf()` into two printf calls. --- examples/benchmark/tls_bench.c | 67 ++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/examples/benchmark/tls_bench.c b/examples/benchmark/tls_bench.c index a2c2fc2bc..55cc3e7a9 100644 --- a/examples/benchmark/tls_bench.c +++ b/examples/benchmark/tls_bench.c @@ -1563,41 +1563,47 @@ static void* server_thread(void* args) #endif /* !NO_WOLFSSL_SERVER */ -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" -#endif static void print_stats(stats_t* wcStat, const char* desc, const char* cipher, const char *group, int verbose) { - const char* formatStr; - if (verbose) { - formatStr = "wolfSSL %s Benchmark on %s with group %s:\n" - "\tTotal : %9d bytes\n" - "\tNum Conns : %9d\n" - "\tRx Total : %9.3f ms\n" - "\tTx Total : %9.3f ms\n" - "\tRx : %9.3f MB/s\n" - "\tTx : %9.3f MB/s\n" - "\tConnect : %9.3f ms\n" - "\tConnect Avg : %9.3f ms\n"; + fprintf(stderr, + "wolfSSL %s Benchmark on %s with group %s:\n" + "\tTotal : %9d bytes\n" + "\tNum Conns : %9d\n" + "\tRx Total : %9.3f ms\n" + "\tTx Total : %9.3f ms\n" + "\tRx : %9.3f MB/s\n" + "\tTx : %9.3f MB/s\n" + "\tConnect : %9.3f ms\n" + "\tConnect Avg : %9.3f ms\n", + desc, + cipher, + group, + wcStat->txTotal + wcStat->rxTotal, + wcStat->connCount, + wcStat->rxTime * 1000, + wcStat->txTime * 1000, + wcStat->rxTotal / wcStat->rxTime / 1024 / 1024, + wcStat->txTotal / wcStat->txTime / 1024 / 1024, + wcStat->connTime * 1000, + wcStat->connTime * 1000 / wcStat->connCount); } else { - formatStr = "%-6s %-33s %-25s %11d %9d %9.3f %9.3f %9.3f %9.3f %17.3f %15.3f\n"; + fprintf(stderr, + "%-6s %-33s %-25s %11d %9d %9.3f %9.3f %9.3f " + "%9.3f %17.3f %15.3f\n", + desc, + cipher, + group, + wcStat->txTotal + wcStat->rxTotal, + wcStat->connCount, + wcStat->rxTime * 1000, + wcStat->txTime * 1000, + wcStat->rxTotal / wcStat->rxTime / 1024 / 1024, + wcStat->txTotal / wcStat->txTime / 1024 / 1024, + wcStat->connTime * 1000, + wcStat->connTime * 1000 / wcStat->connCount); } - - fprintf(stderr, formatStr, - desc, - cipher, - group, - wcStat->txTotal + wcStat->rxTotal, - wcStat->connCount, - wcStat->rxTime * 1000, - wcStat->txTime * 1000, - wcStat->rxTotal / wcStat->rxTime / 1024 / 1024, - wcStat->txTotal / wcStat->txTime / 1024 / 1024, - wcStat->connTime * 1000, - wcStat->connTime * 1000 / wcStat->connCount); } static void Usage(void) @@ -1699,9 +1705,6 @@ static int SetupSupportedGroups(int verbose) } #endif -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif int bench_tls(void* args) {