From: Tvrtko Ursulin <tvrtko.ursu...@intel.com>

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.ursu...@intel.com>
---
 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 fbec23ad1753..59243af5cde8 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -386,7 +386,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);
@@ -394,12 +394,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",
@@ -409,8 +408,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",
@@ -421,8 +419,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",
@@ -442,8 +439,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,
@@ -454,8 +450,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",
@@ -465,8 +460,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",
@@ -476,8 +470,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",
@@ -491,8 +484,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",
@@ -518,8 +510,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",
@@ -551,7 +542,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);
@@ -564,7 +555,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;
 
@@ -592,7 +583,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);
@@ -602,7 +593,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.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to