[PATCH v10 3/5] init/main.c: simplify repair_env_string.

From: Michal Suchanek
Date: Tue Jun 05 2018 - 12:45:09 EST


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@xxxxxxx>
---
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