mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Carmeli Tamir <carmeli.tamir@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: carmeli.tamir@gmail.com, Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs/binfmt_script: Use existing functions to clarify the code
Date: Sat, 18 Jan 2020 11:27:22 -0500	[thread overview]
Message-ID: <20200118162723.21463-1-carmeli.tamir@gmail.com> (raw)

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.

Signed-off-by: Carmeli Tamir <carmeli.tamir@gmail.com>
---
 fs/binfmt_script.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index e9e6a6f4a35f..fc1c4a214690 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -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;
-- 
2.19.1


                 reply	other threads:[~2020-01-18 16:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200118162723.21463-1-carmeli.tamir@gmail.com \
    --to=carmeli.tamir@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®