From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> We can improve the parsing loop readability a bit more by avoiding some line breaks caused by explicit NULL checks. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> --- benchmarks/gem_wsim.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index e6b7b8f5335d..4dbfc3e922a9 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -385,7 +385,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) igt_assert(desc); - while ((_token = strtok_r(tstart, ",", &tctx)) != NULL) { + while ((_token = strtok_r(tstart, ",", &tctx))) { tstart = NULL; token = strdup(_token); igt_assert(token); @@ -393,12 +393,11 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid = 0; memset(&step, 0, sizeof(step)); - if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { fstart = NULL; if (!strcmp(field, "d")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp <= 0, "Invalid delay at step %u!\n", @@ -408,8 +407,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } } else if (!strcmp(field, "p")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp <= 0, "Invalid period at step %u!\n", @@ -420,8 +418,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } } else if (!strcmp(field, "P")) { unsigned int nr = 0; - while ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + while ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n", @@ -441,8 +438,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type = CTX_PRIORITY; goto add_step; } else if (!strcmp(field, "s")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp >= 0 || ((int)nr_steps + tmp) < 0, @@ -453,8 +449,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } } else if (!strcmp(field, "t")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp < 0, "Invalid throttle at step %u!\n", @@ -464,8 +459,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } } else if (!strcmp(field, "q")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp < 0, "Invalid qd throttle at step %u!\n", @@ -475,8 +469,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } } else if (!strcmp(field, "a")) { - if ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(tmp >= 0, "Invalid sw fence signal at step %u!\n", @@ -490,8 +483,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } else if (!strcmp(field, "M")) { unsigned int nr = 0; - while ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + while ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n", @@ -517,8 +509,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } else if (!strcmp(field, "X")) { unsigned int nr = 0; - while ((field = strtok_r(fstart, ".", &fctx)) != - NULL) { + while ((field = strtok_r(fstart, ".", &fctx))) { tmp = atoi(field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n", @@ -558,7 +549,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } - if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { fstart = NULL; i = str_to_engine(field); @@ -571,7 +562,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) bcs_used = true; } - if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { char *sep = NULL; long int tmpl; @@ -599,7 +590,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } - if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { fstart = NULL; tmp = parse_dependencies(nr_steps, &step, field); @@ -609,7 +600,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } - if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { + if ((field = strtok_r(fstart, ".", &fctx))) { fstart = NULL; check_arg(strlen(field) != 1 || -- 2.19.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx