Skip to contentSkip to conversation

fs/binfmt_script: Use existing functions to clarify the code

PATCH New Carmeli Tamir 1 participant 1 message Jan 18, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/binfmt_script: Use existing functions to clarify the code

This patch applies the recently defined 'spacetab', 'next_non_spacetab' and 'next_terminator' functions to more places in the code, improving its readability and reducing code duplication.

---
 fs/binfmt_script.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/binfmt_script.c +4 -5
index e9e6a6f4a35f..fc1c4a214690 100644
@@ -88,19 +88,18 @@ static int load_script(struct linux_binprm *bprm)
 	*cp = '\0';
 	while (cp > bprm->buf) {
 		cp--;
-		if ((*cp == ' ') || (*cp == '\t'))
+		if (spacetab(*cp))
 			*cp = '\0';
 		else
 			break;
 	}
-	for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
+	cp = next_non_spacetab(bprm->buf+2, buf_end);
 	if (*cp == '\0')
 		return -ENOEXEC; /* No interpreter name found */
 	i_name = cp;
 	i_arg = NULL;
-	for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++)
-		/* nothing */ ;
-	while ((*cp == ' ') || (*cp == '\t'))
+	cp = next_terminator(cp, buf_end);
+	while (spacetab(*cp))
 		*cp++ = '\0';
 	if (*cp)
 		i_arg = cp;
Signature · 1 line
2.19.1