diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index 23d662184e1b6c868b1139f96053ca3540112e60..6301e3e80352acd00f04e6d133c916eaacefe065 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -242,12 +242,11 @@ static void DoSetDomainname(const char *cmdContent, int maxArg) INIT_LOGE("DoSetHostname failed to write %s to \"/proc/sys/kernel/domainname\". err = %d", errno); } - if (fd > 0) { - close(fd); - fd = -1; - } + close(fd); + fd = -1; out: FreeCmd(&ctx); + fd = -1; return; } @@ -267,12 +266,11 @@ static void DoSetHostname(const char *cmdContent, int maxArg) INIT_LOGE("DoSetHostname failed to write %s to \"/proc/sys/kernel/hostname\". err = %d", errno); } - if (fd > 0) { - close(fd); - fd = -1; - } + close(fd); + fd = -1; out: FreeCmd(&ctx); + fd = -1; return; }