diff --git a/services/BUILD.gn b/services/BUILD.gn index 1fb8e4cbab2fb62200fdbd34bbf3ea8e0ea016db..b2b9065f8c9f578cca807def2edf4e1de8c961df 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -21,7 +21,7 @@ if (defined(ohos_lite)) { executable("init") { defines = [ "_GNU_SOURCE", #syscall function need this macro definition - "OHOS_LITE=1", + "OHOS_LITE", ] sources = [ "src/init_adapter.c", @@ -97,7 +97,6 @@ if (defined(ohos_lite)) { "src/init_signal_handler.c", "src/device.c", ] - defines = [ "OHOS_LITE=0" ] include_dirs = [ "include", "//third_party/cJSON", diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index 6f3f22666a4b64a6964147c40a36195a22587ab3..587d3eaa2703265820eff755d0d76967153963f0 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -24,7 +24,7 @@ #include #include #include -#if !OHOS_LITE +#ifndef OHOS_LITE #include #include #include @@ -320,7 +320,7 @@ static void DoMount(const char* cmdContent) free(target); } -#if !OHOS_LITE +#ifndef OHOS_LITE // format insmod [-f] [options] static void DoInsmod(const char *cmdContent) { @@ -370,10 +370,12 @@ static void DoInsmod(const char *cmdContent) if (p != NULL) { if (restPtr != NULL) { if (snprintf_s(options, sizeof(options), OPTIONS_SIZE -1, "%s %s", p, restPtr) == -1) { + goto out; return; } } else { if (strncpy_s(options, OPTIONS_SIZE - 1, p, strlen(p)) != 0) { + goto out; return; } } @@ -487,7 +489,7 @@ void DoCmd(const CmdLine* curCmd) } else if (strncmp(curCmd->name, "loadcfg ", strlen("loadcfg ")) == 0) { DoLoadCfg(curCmd->cmdContent); } -#if !OHOS_LITE +#ifndef OHOS_LITE else if (strncmp(curCmd->name, "insmod ", strlen("insmod ")) == 0) { DoInsmod(curCmd->cmdContent); } diff --git a/services/src/main.c b/services/src/main.c index 0c116e7d8d853d896a90e8c8f4f07f08c891fd63..acdc8e373c544c9c0654dc98fcdf8922c7067823 100755 --- a/services/src/main.c +++ b/services/src/main.c @@ -27,11 +27,11 @@ #include "init_adapter.h" #include "init_read_cfg.h" #include "init_signal_handler.h" -#if OHOS_LITE +#ifdef OHOS_LITE #include "parameter.h" #endif -#if !OHOS_LITE +#ifndef OHOS_LITE #include "device.h" #endif @@ -39,7 +39,7 @@ static const pid_t INIT_PROCESS_PID = 1; static void PrintSysInfo() { -#if OHOS_LITE +#ifdef OHOS_LITE char* sysInfo = GetVersionId(); if (sysInfo != NULL) { printf("[Init] %s\n", sysInfo); @@ -80,7 +80,7 @@ int main(int argc, char * const argv[]) // 1. print system info PrintSysInfo(); -#if !OHOS_LITE +#ifndef OHOS_LITE // 2. Mount basic filesystem and create common device node. MountBasicFs(); CreateDeviceNode(); diff --git a/services/test/unittest/common/BUILD.gn b/services/test/unittest/common/BUILD.gn index 8214e3a4eddf69685c4b39d17d4f382b93a40e41..e9b94934e3b76fab3e1c1e45ae2d16db13eb0682 100644 --- a/services/test/unittest/common/BUILD.gn +++ b/services/test/unittest/common/BUILD.gn @@ -21,9 +21,9 @@ unittest("init_test") { "-lpthread", "-lm", ] - + defines = ["OHOS_LITE"] if (storage_type == "emmc") { - defines = [ "USE_EMMC_STORAGE" ] + defines += [ "USE_EMMC_STORAGE" ] } include_dirs = [ "//base/startup/init_lite/services/include" ]