threads / patch / 42331

patchattr.c: use strchrnul() to scan for one line

Subject: [PATCH] attr.c: use strchrnul() to scan for one line

## tl;dr

One message between May 15, 2016 and May 15, 2016. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· May 15, 2016, 22:28 UTC · lore
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to attr.c +2 −2
diff --git a/attr.c b/attr.c
index a19946a..a7f2c3f 100644
--- a/attr.c
+++ b/attr.c
@@ -407,8 +407,8 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
 	for (sp = buf; *sp; ) {
 		char *ep;
 		int more;
-		for (ep = sp; *ep && *ep != '\n'; ep++)
-			;
+
+		ep = strchrnul(sp, '\n');
 		more = (*ep == '\n');
 		*ep = '\0';
 		handle_attr_line(res, sp, path, ++lineno, macro_ok);
-- 
2.8.2-748-gfb85f76

← back to recent threads