From 4a2f3fe69ab0fdc9e3e9a807019b96b7df0e3c6c Mon Sep 17 00:00:00 2001 From: sun_fan Date: Thu, 16 Sep 2021 19:41:03 +0800 Subject: [PATCH] init: fix mkdir bug Signed-off-by: sun_fan --- services/src/init_cmds.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index 9663b4349..754e1ae46 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -528,16 +528,18 @@ static void DoMkDir(const char *cmdContent, int maxArg) break; } index = index + 1; - if ((ctx->argv[index] != NULL) && (ctx->argv[index + 1] != NULL)) { - rc = Chown(ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]); - } else { - rc = -1; + if (ctx->argv[index] != NULL) { + if (ctx->argv[index + 1] != NULL) { + rc = Chown(ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]); + } else { + rc = -1; + } } } } while (0); if (rc < 0) { - INIT_LOGE("Run command mkdir failed err = %d", errno); + INIT_LOGE("Run command mkdir %s failed err = %d", ctx->argv[0], errno); (void)rmdir(ctx->argv[0]); } FreeCmd(ctx); @@ -1306,4 +1308,4 @@ const char *GetCmdKey(unsigned int index) return NULL; } return CMD_TABLE[index].name; -} \ No newline at end of file +} -- Gitee