From 412d804cfcb8d9182ae7aaaaef3cc7c306b75d83 Mon Sep 17 00:00:00 2001 From: Brett Nicholas <7547222+bigbrett@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:38:08 -0600 Subject: [PATCH] macro protection and compiler warning fixes --- benchmark/bench_modules/wh_bench_mod_sha2.c | 8 ++++++-- benchmark/config/wolfhsm_cfg.h | 1 + benchmark/wh_bench_main.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/benchmark/bench_modules/wh_bench_mod_sha2.c b/benchmark/bench_modules/wh_bench_mod_sha2.c index 74df2ddd5..32d81b7fb 100644 --- a/benchmark/bench_modules/wh_bench_mod_sha2.c +++ b/benchmark/bench_modules/wh_bench_mod_sha2.c @@ -53,6 +53,8 @@ int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id, #if defined(WOLFHSM_CFG_DMA) if (devId == WH_DEV_ID_DMA) { inLen = WOLFHSM_CFG_BENCH_DMA_BUFFER_SIZE; + +#if defined(WOLFHSM_CFG_TEST_POSIX) if (ctx->transportType == WH_BENCH_TRANSPORT_POSIX_DMA) { /* if static memory was used with DMA then use XMALLOC */ void* heap = @@ -68,7 +70,9 @@ int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id, return WH_ERROR_NOSPACE; } } - else { + else +#endif /* WOLFHSM_CFG_TEST_POSIX */ + { in = WH_BENCH_DMA_BUFFER; } } @@ -138,7 +142,7 @@ int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id, (void)wc_Sha256Free(sha256); } -#if defined(WOLFHSM_CFG_DMA) +#if defined(WOLFHSM_CFG_DMA) && defined(WOLFHSM_CFG_TEST_POSIX) if (devId == WH_DEV_ID_DMA && ctx->transportType == WH_BENCH_TRANSPORT_POSIX_DMA) { /* if static memory was used with DMA then use XFREE */ diff --git a/benchmark/config/wolfhsm_cfg.h b/benchmark/config/wolfhsm_cfg.h index 2a2fa7d38..4c1463758 100644 --- a/benchmark/config/wolfhsm_cfg.h +++ b/benchmark/config/wolfhsm_cfg.h @@ -43,4 +43,5 @@ /* Benchmark configs */ #define WOLFHSM_CFG_BENCH_ENABLE +#define WOLFHSM_CFG_BENCH_MAIN #endif /* WOLFHSM_CFG_H_ */ diff --git a/benchmark/wh_bench_main.c b/benchmark/wh_bench_main.c index 3ef8e5189..c36215359 100644 --- a/benchmark/wh_bench_main.c +++ b/benchmark/wh_bench_main.c @@ -21,7 +21,7 @@ #include "wh_bench_ops.h" #include "wh_bench_utils.h" -#if defined(WOLFHSM_CFG_BENCH_ENABLE) +#if defined(WOLFHSM_CFG_BENCH_ENABLE) && defined(WOLFHSM_CFG_BENCH_MAIN) #include #include @@ -95,4 +95,4 @@ int main(int argc, char** argv) return 0; } -#endif /* WOLFHSM_CFG_BENCH_ENABLE */ +#endif /* WOLFHSM_CFG_BENCH_ENABLE && WOLFHSM_CFG_BENCH_MAIN */