From 9d8fc5e4351ba93617db379d30482bdc7deea3b8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 29 Nov 2017 20:51:09 -0700 Subject: [PATCH] Unify max split zone support We have two different defines, use the one from the networking protocol. Add a compile time check that bssplit and zones have the same max, so we don't inadvertently add an overflow condition if we change one of them. Signed-off-by: Jens Axboe --- libfio.c | 1 + options.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libfio.c b/libfio.c index d9900add..c9bb8f3f 100644 --- a/libfio.c +++ b/libfio.c @@ -366,6 +366,7 @@ int initialize_fio(char *envp[]) compiletime_assert((offsetof(struct jobs_eta, m_rate) % 8) == 0, "m_rate"); compiletime_assert(__TD_F_LAST <= TD_ENG_FLAG_SHIFT, "TD_ENG_FLAG_SHIFT"); + compiletime_assert(BSSPLIT_MAX == ZONESPLIT_MAX, "bsssplit/zone max"); err = endian_check(); if (err) { diff --git a/options.c b/options.c index d979f804..2a530226 100644 --- a/options.c +++ b/options.c @@ -54,12 +54,10 @@ static int bs_cmp(const void *p1, const void *p2) return (int) bsp1->perc - (int) bsp2->perc; } -#define SPLIT_MAX_ENTRY 100 - struct split { unsigned int nr; - unsigned int val1[SPLIT_MAX_ENTRY]; - unsigned long long val2[SPLIT_MAX_ENTRY]; + unsigned int val1[ZONESPLIT_MAX]; + unsigned long long val2[ZONESPLIT_MAX]; }; static int split_parse_ddir(struct thread_options *o, struct split *split, @@ -111,7 +109,7 @@ static int split_parse_ddir(struct thread_options *o, struct split *split, split->val1[i] = val; split->val2[i] = perc; i++; - if (i == SPLIT_MAX_ENTRY) + if (i == ZONESPLIT_MAX) break; } -- 2.25.1