From 3a4185be1924a430d660f7e76b4ef84f18afd9af Mon Sep 17 00:00:00 2001 From: wuzhouhui Date: Fri, 14 Dec 2018 12:43:27 +0800 Subject: [PATCH] reduce: check strlen(SPDK_REDUCE_SIGNATURE) in buildtime Change-Id: I4d12f2a693a4a34c840d972a4f60cbd0fc35011b Signed-off-by: wuzhouhui Reviewed-on: https://review.gerrithub.io/437236 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/reduce/reduce.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index 123b115e4..fd5e6f0d4 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -45,8 +45,6 @@ /* Always round up the size of the PM region to the nearest cacheline. */ #define REDUCE_PM_SIZE_ALIGNMENT 64 -#define SPDK_REDUCE_SIGNATURE "SPDKREDU" - /* Offset into the backing device where the persistent memory file's path is stored. */ #define REDUCE_BACKING_DEV_PATH_OFFSET 4096 @@ -62,6 +60,11 @@ struct spdk_reduce_vol_superblock { }; SPDK_STATIC_ASSERT(sizeof(struct spdk_reduce_vol_superblock) == 4096, "size incorrect"); +#define SPDK_REDUCE_SIGNATURE "SPDKREDU" +/* null terminator counts one */ +SPDK_STATIC_ASSERT(sizeof(SPDK_REDUCE_SIGNATURE) - 1 == + sizeof(((struct spdk_reduce_vol_superblock *)0)->signature), "size incorrect"); + #define REDUCE_PATH_MAX 4096 /**