From 8cdd1c97f5f1a1b8473f3ad0b6ce55fe99f8cd6c Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki Date: Thu, 31 Dec 2020 11:56:45 +0100 Subject: [PATCH] Fix incorrect check in CountSpaces CountSpaces contains an expression that always evaluated to false. Quick analysis indicates that it's a simple coding mistake and that the `+ 1` part should refer to both the array element and element value. Fixes: https://gitee.com/openharmony/startup_init_lite/issues/I2BKV5 Signed-off-by: Zygmunt Krynicki --- src/init_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init_cmds.c b/src/init_cmds.c index 90b9c2119..8713945a7 100755 --- a/src/init_cmds.c +++ b/src/init_cmds.c @@ -242,7 +242,7 @@ static int CountSpaces(const char* cmdContent, size_t* spaceCnt, size_t* spacePo // spaces should not be adjacent for (size_t i = 0; i < numSpaces - 1; ++i) { - if (spacePosArr[i] == spacePosArr[i] + 1) { + if (spacePosArr[i] + 1 == spacePosArr[i + 1]) { printf("[Init] DoMount, bad format for %s.\n", cmdContent); return 0; } -- Gitee