Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756559AbdLOVd2 (ORCPT ); Fri, 15 Dec 2017 16:33:28 -0500 Received: from mx2.suse.de ([195.135.220.15]:59618 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755857AbdLOVdZ (ORCPT ); Fri, 15 Dec 2017 16:33:25 -0500 From: Michal Suchanek To: Hari Bathini , Ingo Molnar , Andrew Morton , Thomas Gleixner , Kees Cook , Peter Zijlstra , "Steven Rostedt," , Laura Abbott , Gargi Sharma , Tom Lendacky , Michal Suchanek , Viresh Kumar , linux-kernel@vger.kernel.org Subject: [PATCH] init/main.c: simplify repair_env_string Date: Fri, 15 Dec 2017 22:33:17 +0100 Message-Id: <20171215213317.3151-1-msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: <151075904367.14434.5164139208561977016.stgit@hbathini.in.ibm.com> References: <151075904367.14434.5164139208561977016.stgit@hbathini.in.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1052 Lines: 38 Quoting characters are now removed from the parameter so value always follows directly after the NUL terminating parameter name. Signed-off-by: Michal Suchanek --- init/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) Since the previous "[PATCH v9 3/8] lib/cmdline.c: add backslash support to kernel commandline parsing" adds the memmove in lib/cmdline.c it is now superfluous in init/main.c diff --git a/init/main.c b/init/main.c index 1f5fdedbb293..1e5b1dc940d9 100644 --- a/init/main.c +++ b/init/main.c @@ -244,15 +244,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