git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/7] Change while loop into for loop

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Aug 12, 2011, 21:43 UTC
Message-ID
<1313185390-19724-7-git-send-email-mhagger@alum.mit.edu>
In-Reply-To
<1313185390-19724-1-git-send-email-mhagger@alum.mit.edu>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 attr.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/attr.c b/attr.c
index a7d1aa9..b56542e 100644
--- a/attr.c
+++ b/attr.c
@@ -228,14 +228,11 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
 
 	for (pass = 0; pass < 2; pass++) {
 		/* pass 0 counts and allocates, pass 1 fills */
-		num_attr = 0;
-		cp = states;
-		while (*cp) {
+		for (cp = states, num_attr = 0; *cp; num_attr++) {
 			cp = parse_attr(src, lineno, cp,
 				pass ? &(res->state[num_attr]) : NULL);
 			if (!cp)
 				return NULL;
-			num_attr++;
 		}
 		if (pass)
 			break;
-- 
1.7.6.8.gd2879
Previous: Michael HaggertyNext: Michael Haggerty
Message 7 of 8 in “Comments and refactoring in attr.c”
  1. 0/7 Comments and refactoring in attr.cMichael Haggerty, Aug 12, 2011
  2. 1/7 Add a file commentMichael Haggerty, Aug 12, 2011
  3. 2/7 Document struct match_attrMichael Haggerty, Aug 12, 2011
  4. 3/7 Increment num_attr in parse_attr_line(), not parse_attr()Michael Haggerty, Aug 12, 2011
  5. 4/7 Change parse_attr() to take a pointer to struct attr_stateMichael Haggerty, Aug 12, 2011
  6. 5/7 Determine the start of the states outside of the pass loopMichael Haggerty, Aug 12, 2011
  7. 6/7 Change while loop into for loopMichael Haggerty, Aug 12, 2011
  8. 7/7 Unroll the loop over passesMichael Haggerty, Aug 12, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.