diff options
| author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-05-27 10:43:58 +0100 |
|---|---|---|
| committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-06-03 18:55:34 +0100 |
| commit | 248c71f76446fd899a1afe5da988a0b6544b96b4 (patch) | |
| tree | e33e88e1783510fd237e2f363c977f4d8e845b04 /benchmarks | |
| parent | 6cfbf0365f39d68fcaabcd0498ffec28d1528d8f (diff) | |
benchmarks/gem_wsim: Tidy manual sizeof VLA calculations
We can use offsetof for the same effect, much tidier with no dummy
locals.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'benchmarks')
| -rw-r--r-- | benchmarks/gem_wsim.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index db19925b..a76fdbfe 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -1443,23 +1443,20 @@ set_ctx_sseu(struct ctx *ctx, uint64_t slice_mask) static size_t sizeof_load_balance(int count) { - struct i915_context_engines_load_balance *ptr; - - return sizeof(*ptr) + count * sizeof(ptr->engines[0]); + return offsetof(struct i915_context_engines_load_balance, + engines[count]); } static size_t sizeof_param_engines(int count) { - struct i915_context_param_engines *ptr; - - return sizeof(*ptr) + count * sizeof(ptr->engines[0]); + return offsetof(struct i915_context_param_engines, + engines[count]); } static size_t sizeof_engines_bond(int count) { - struct i915_context_engines_bond *ptr; - - return sizeof(*ptr) + count * sizeof(ptr->engines[0]); + return offsetof(struct i915_context_engines_bond, + engines[count]); } #define alloca0(sz) ({ size_t sz__ = (sz); memset(alloca(sz__), 0, sz__); }) |
