From 3f3398b2364f53af86f84878e8ab98e1db487512 Mon Sep 17 00:00:00 2001 From: Gymee <8039110+Gymee@user.noreply.gitee.com> Date: Sat, 19 Sep 2020 20:33:28 +0800 Subject: [PATCH] move _GNU_SOURCE to build.gn and format header files as per huawei coding proactice --- BUILD.gn | 4 ++++ include/init_adapter.h | 2 +- src/init_adapter.c | 3 ++- src/init_cmds.c | 3 +++ src/init_jobs.c | 3 +++ src/init_read_cfg.c | 3 +++ src/init_service.c | 2 ++ src/init_service_manager.c | 3 +++ src/init_signal_handler.c | 2 ++ src/main.c | 2 ++ 10 files changed, 25 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 6f31f535..f0c6a531 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -20,6 +20,10 @@ lite_component("init_lite") { # feature: init executable("init") { + defines = [ + "_GNU_SOURCE", #syscall function need this macro definition + ] + sources = [ "src/main.c", "src/init_cmds.c", diff --git a/include/init_adapter.h b/include/init_adapter.h index 3c111c80..4a2bd784 100755 --- a/include/init_adapter.h +++ b/include/init_adapter.h @@ -15,7 +15,7 @@ #ifndef BASE_STARTUP_INITLITE_ADAPTER_H #define BASE_STARTUP_INITLITE_ADAPTER_H -#define _GNU_SOURCE // syscall function need this macro definition + #ifdef __LINUX__ #include #else diff --git a/src/init_adapter.c b/src/init_adapter.c index b897f770..b07aceb6 100755 --- a/src/init_adapter.c +++ b/src/init_adapter.c @@ -12,8 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#define _GNU_SOURCE // syscall function need this macro definition + #include "init_adapter.h" + #include #include #include diff --git a/src/init_cmds.c b/src/init_cmds.c index 1da1c11c..e09a46a9 100755 --- a/src/init_cmds.c +++ b/src/init_cmds.c @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "init_cmds.h" + #include #include #include @@ -21,6 +23,7 @@ #include #include #include + #include "init_service_manager.h" #include "securec.h" diff --git a/src/init_jobs.c b/src/init_jobs.c index d3114a87..c2771951 100755 --- a/src/init_jobs.c +++ b/src/init_jobs.c @@ -12,9 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "init_jobs.h" + #include #include + #include "init_cmds.h" #include "securec.h" diff --git a/src/init_read_cfg.c b/src/init_read_cfg.c index bc2c63e0..fb0b1e4f 100755 --- a/src/init_read_cfg.c +++ b/src/init_read_cfg.c @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "init_read_cfg.h" + #include #include #include @@ -20,6 +22,7 @@ #include #include #include + #include "init_jobs.h" #include "init_perms.h" #include "init_service_manager.h" diff --git a/src/init_service.c b/src/init_service.c index 201414bc..52b192bd 100755 --- a/src/init_service.c +++ b/src/init_service.c @@ -14,12 +14,14 @@ */ #include "init_service.h" + #include #include #include #include #include #include + #include "init_adapter.h" #include "init_perms.h" diff --git a/src/init_service_manager.c b/src/init_service_manager.c index d574106e..fa8dc9e8 100755 --- a/src/init_service_manager.c +++ b/src/init_service_manager.c @@ -12,10 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "init_service_manager.h" + #include #include #include + #include "init_adapter.h" #include "init_jobs.h" diff --git a/src/init_signal_handler.c b/src/init_signal_handler.c index 6919886f..d951ec34 100755 --- a/src/init_signal_handler.c +++ b/src/init_signal_handler.c @@ -14,9 +14,11 @@ */ #include "init_signal_handler.h" + #include #include #include + #include "init_service_manager.h" static void SigHandler(int sig) diff --git a/src/main.c b/src/main.c index 6ee267c0..fdbaed14 100755 --- a/src/main.c +++ b/src/main.c @@ -12,9 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include + #include "init_read_cfg.h" #include "init_signal_handler.h" #include "parameter.h" -- GitLab