From 55b16251431b542d10e81302d1a3a68bab4d42f5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 9 Jul 2022 08:11:44 -0700 Subject: [PATCH] smyrna: simplify inner 'load_attributes' loop This loop contains no `continue` statements, its counter is incremented in a regular way, and the counter is unused outside the loop. So we can write the loop more concisely and scope `ind` more tightly by using a `for` loop instead of a `while` loop. --- cmd/smyrna/gui/gui.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/smyrna/gui/gui.c b/cmd/smyrna/gui/gui.c index 8dc327b50..d79747ae9 100644 --- a/cmd/smyrna/gui/gui.c +++ b/cmd/smyrna/gui/gui.c @@ -44,7 +44,6 @@ void load_attributes(void) char line[BUFSIZ]; char *ss; char *pch; - int ind = 0; int attrcount = 0; static char *smyrna_attrs; @@ -56,8 +55,7 @@ void load_attributes(void) if (file != NULL) { while (fgets(line, sizeof line, file) != NULL) { pch = strtok(line, ","); - ind = 0; - while (pch != NULL) { + for (int ind = 0; pch != NULL; ++ind) { ss = strdup(pch); pch = strtok(NULL, ","); switch (ind) { @@ -102,7 +100,6 @@ void load_attributes(void) attr[attrcount].ComboValuesCount++; break; } - ind++; } attrcount++; } -- 2.40.0