From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> v2: * Remove redundant check. (Chris) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- benchmarks/gem_wsim.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index 464314c05697..60b7d32e22d4 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -318,6 +318,18 @@ wsim_err(const char *fmt, ...) } \ } +static int str_to_engine(const char *str) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ring_str_map); i++) { + if (!strcasecmp(str, ring_str_map[i])) + return i; + } + + return -1; +} + static struct workload * parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) { @@ -480,22 +492,18 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { - unsigned int old_valid = valid; - fstart = NULL; - for (i = 0; i < ARRAY_SIZE(ring_str_map); i++) { - if (!strcasecmp(field, ring_str_map[i])) { - step.engine = i; - if (step.engine == BCS) - bcs_used = true; - valid++; - break; - } - } - - check_arg(old_valid == valid, + i = str_to_engine(field); + check_arg(i < 0, "Invalid engine id at step %u!\n", nr_steps); + + valid++; + + step.engine = i; + + if (step.engine == BCS) + bcs_used = true; } if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { -- 2.20.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx