mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Suchanek <msuchanek@suse.de>
To: Jonathan Corbet <corbet@lwn.net>,
	Michal Suchanek <msuchanek@suse.de>,
	Arnd Bergmann <arnd@arndb.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Aaron Wu <Aaron.Wu@analog.com>,
	Tony Luck <tony.luck@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Steven Rostedt," <rostedt@goodmis.org>,
	Laura Abbott <lauraa@codeaurora.org>,
	Dominik Brodowski <linux@dominikbrodowski.net>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Jeffrey Hugo <jhugo@codeaurora.org>, Baoquan He <bhe@redhat.com>,
	Ilya Matveychikov <matvejchikov@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v10 3/5] init/main.c: simplify repair_env_string.
Date: Tue,  5 Jun 2018 18:43:10 +0200	[thread overview]
Message-ID: <f0d9664cf6e10cd89c8fa551885b91a75619b267.1528215659.git.msuchanek@suse.de> (raw)
In-Reply-To: <cover.1528215659.git.msuchanek@suse.de>
In-Reply-To: <cover.1528215659.git.msuchanek@suse.de>

Quoting characters are now removed from the parameter so value always
follows directly after the NUL terminating parameter name.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 init/main.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/init/main.c b/init/main.c
index 4bc2819d97ad..d0f4a7a0f010 100644
--- a/init/main.c
+++ b/init/main.c
@@ -251,15 +251,10 @@ static int __init repair_env_string(char *param, char *val,
 				    const char *unused, void *arg)
 {
 	if (val) {
-		/* param=val or param="val"? */
-		if (val == param+strlen(param)+1)
-			val[-1] = '=';
-		else if (val == param+strlen(param)+2) {
-			val[-2] = '=';
-			memmove(val-1, val, strlen(val)+1);
-			val--;
-		} else
-			BUG();
+		int parm_len = strlen(param);
+
+		param[parm_len] = '=';
+		BUG_ON(val != param + parm_len + 1);
 	}
 	return 0;
 }
-- 
2.13.6

  parent reply	other threads:[~2018-06-05 16:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 16:43 [PATCH v10 0/5] Kernel parameter parser cleanup/enhancement Michal Suchanek
2018-06-05 16:43 ` [PATCH v10 1/5] lib/cmdline.c: Add backslash support to kernel commandline parsing Michal Suchanek
2018-06-05 16:43 ` [PATCH v10 2/5] Documentation/admin-guide: backslash support in kernel arguments Michal Suchanek
2018-06-05 16:43 ` Michal Suchanek [this message]
2018-06-05 16:43 ` [PATCH v10 4/5] lib/cmdline.c: Implement single quotes in commandline argument parsing Michal Suchanek
2018-06-05 16:43 ` [PATCH v10 5/5] Documentation/admin-guide: single quotes in kernel arguments Michal Suchanek
2018-06-05 17:05 ` [PATCH v10 0/5] Kernel parameter parser cleanup/enhancement Andy Shevchenko
2018-06-05 17:25   ` Michal Suchánek
2018-06-19 23:36 ` Andrew Morton
2018-06-20 10:47   ` Michal Suchánek

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=f0d9664cf6e10cd89c8fa551885b91a75619b267.1528215659.git.msuchanek@suse.de \
    --to=msuchanek@suse.de \
    --cc=Aaron.Wu@analog.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bhe@redhat.com \
    --cc=corbet@lwn.net \
    --cc=frederic@kernel.org \
    --cc=jhugo@codeaurora.org \
    --cc=lauraa@codeaurora.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=matvejchikov@gmail.com \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tony.luck@intel.com \
    /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®