From a7fffa9e0059ed9a7f4b0a1f9bb89c5e4209bc5a Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Thu, 13 Sep 2018 15:06:35 -0700 Subject: [PATCH] headers: Fix headers guards Any word started with underscore followed by and uppercase letter or a second underscore is a reserved word according with C99. With have *many* violations on Zephyr's code, this commit is tackling only the violations caused by headers guards. It also takes the opportunity to normalize them using the filename in uppercase and replacing dot with underscore. e.g file.h -> FILE_H Signed-off-by: Flavio Ceolin --- kernel/include/gen_offset.h | 6 +++--- kernel/include/kernel_internal.h | 6 +++--- kernel/include/kernel_offsets.h | 6 +++--- kernel/include/kernel_structs.h | 6 +++--- kernel/include/ksched.h | 6 +++--- kernel/include/kswap.h | 6 +++--- kernel/include/offsets_short.h | 6 +++--- kernel/include/syscall_handler.h | 6 +++--- kernel/include/timeout_q.h | 6 +++--- kernel/include/wait_q.h | 6 +++--- scripts/dts/extract_dts_includes.py | 4 ++-- scripts/gen_kobject_list.py | 6 +++--- scripts/gen_syscalls.py | 6 +++--- 13 files changed, 38 insertions(+), 38 deletions(-) diff --git a/kernel/include/gen_offset.h b/kernel/include/gen_offset.h index 0fd71a3bbb7..1fa1da5f689 100644 --- a/kernel/include/gen_offset.h +++ b/kernel/include/gen_offset.h @@ -68,8 +68,8 @@ * 0000000c A ___kernel_t_idle_OFFSET */ -#ifndef _GEN_OFFSET_H -#define _GEN_OFFSET_H +#ifndef ZEPHYR_KERNEL_INCLUDE_GEN_OFFSET_H_ +#define ZEPHYR_KERNEL_INCLUDE_GEN_OFFSET_H_ #include #include @@ -79,4 +79,4 @@ #define GEN_OFFSET_SYM(S, M) \ GEN_ABSOLUTE_SYM(__##S##_##M##_##OFFSET, offsetof(S, M)) -#endif /* _GEN_OFFSET_H */ +#endif /* ZEPHYR_KERNEL_INCLUDE_GEN_OFFSET_H_ */ diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h index a90878318d9..9b15c59d3c0 100644 --- a/kernel/include/kernel_internal.h +++ b/kernel/include/kernel_internal.h @@ -11,8 +11,8 @@ * This file contains private kernel APIs that are not architecture-specific. */ -#ifndef _NANO_INTERNAL__H_ -#define _NANO_INTERNAL__H_ +#ifndef ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_ +#define ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_ #include @@ -232,4 +232,4 @@ extern int z_stack_adjust_initialized; #endif /* _ASMLANGUAGE */ -#endif /* _NANO_INTERNAL__H_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_ */ diff --git a/kernel/include/kernel_offsets.h b/kernel/include/kernel_offsets.h index a3a8b1e6fdb..d129f7d4be5 100644 --- a/kernel/include/kernel_offsets.h +++ b/kernel/include/kernel_offsets.h @@ -5,8 +5,8 @@ */ #include -#ifndef _kernel_offsets__h_ -#define _kernel_offsets__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_KERNEL_OFFSETS_H_ +#define ZEPHYR_KERNEL_INCLUDE_KERNEL_OFFSETS_H_ #include @@ -80,4 +80,4 @@ GEN_ABSOLUTE_SYM(K_THREAD_SIZEOF, sizeof(struct k_thread)); /* size of the device structure. Used by linker scripts */ GEN_ABSOLUTE_SYM(_DEVICE_STRUCT_SIZE, sizeof(struct device)); -#endif /* _kernel_offsets__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_OFFSETS_H_ */ diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index 505da0bb74b..96b1f5f7659 100644 --- a/kernel/include/kernel_structs.h +++ b/kernel/include/kernel_structs.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _kernel_structs__h_ -#define _kernel_structs__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_KERNEL_STRUCTS_H_ +#define ZEPHYR_KERNEL_INCLUDE_KERNEL_STRUCTS_H_ #include @@ -248,4 +248,4 @@ static ALWAYS_INLINE void _new_thread_init(struct k_thread *thread, #endif /* _ASMLANGUAGE */ -#endif /* _kernel_structs__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_STRUCTS_H_ */ diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 93bf6bb6a28..89911c1babe 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _ksched__h_ -#define _ksched__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_KSCHED_H_ +#define ZEPHYR_KERNEL_INCLUDE_KSCHED_H_ #include #include @@ -287,4 +287,4 @@ static inline struct k_thread *_unpend1_no_timeout(_wait_q_t *wait_q) return thread; } -#endif /* _ksched__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_KSCHED_H_ */ diff --git a/kernel/include/kswap.h b/kernel/include/kswap.h index 01ac1f07533..7096ad77b71 100644 --- a/kernel/include/kswap.h +++ b/kernel/include/kswap.h @@ -3,8 +3,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _KSWAP_H -#define _KSWAP_H +#ifndef ZEPHYR_KERNEL_INCLUDE_KSWAP_H_ +#define ZEPHYR_KERNEL_INCLUDE_KSWAP_H_ #include #include @@ -110,4 +110,4 @@ static inline int _Swap(unsigned int key) } #endif -#endif /* _KSWAP_H */ +#endif /* ZEPHYR_KERNEL_INCLUDE_KSWAP_H_ */ diff --git a/kernel/include/offsets_short.h b/kernel/include/offsets_short.h index ac73d154750..bd490741776 100644 --- a/kernel/include/offsets_short.h +++ b/kernel/include/offsets_short.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _offsets_short__h_ -#define _offsets_short__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_OFFSETS_SHORT_H_ +#define ZEPHYR_KERNEL_INCLUDE_OFFSETS_SHORT_H_ #include #include @@ -64,4 +64,4 @@ /* end - threads */ -#endif /* _offsets_short__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_OFFSETS_SHORT_H_ */ diff --git a/kernel/include/syscall_handler.h b/kernel/include/syscall_handler.h index a0d595097eb..f2d23840cfa 100644 --- a/kernel/include/syscall_handler.h +++ b/kernel/include/syscall_handler.h @@ -5,8 +5,8 @@ */ -#ifndef _ZEPHYR_SYSCALL_HANDLER_H_ -#define _ZEPHYR_SYSCALL_HANDLER_H_ +#ifndef ZEPHYR_KERNEL_INCLUDE_SYSCALL_HANDLER_H_ +#define ZEPHYR_KERNEL_INCLUDE_SYSCALL_HANDLER_H_ #ifdef CONFIG_USERSPACE @@ -605,4 +605,4 @@ static inline int _obj_validation_check(struct _k_object *ko, #endif /* CONFIG_USERSPACE */ -#endif /* _ZEPHYR_SYSCALL_H_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_SYSCALL_HANDLER_H_ */ diff --git a/kernel/include/timeout_q.h b/kernel/include/timeout_q.h index e911a7dba57..f290e9badf0 100644 --- a/kernel/include/timeout_q.h +++ b/kernel/include/timeout_q.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _kernel_include_timeout_q__h_ -#define _kernel_include_timeout_q__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_ +#define ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_ /** * @file @@ -290,4 +290,4 @@ static inline s32_t _get_next_timeout_expiry(void) } #endif -#endif /* _kernel_include_timeout_q__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_ */ diff --git a/kernel/include/wait_q.h b/kernel/include/wait_q.h index 6aea2d30fc6..fadc255c535 100644 --- a/kernel/include/wait_q.h +++ b/kernel/include/wait_q.h @@ -6,8 +6,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _kernel_include_wait_q__h_ -#define _kernel_include_wait_q__h_ +#ifndef ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_ +#define ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_ #include #include @@ -85,4 +85,4 @@ static inline struct k_thread *_waitq_head(_wait_q_t *w) } #endif -#endif /* _kernel_include_wait_q__h_ */ +#endif /* ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_ */ diff --git a/scripts/dts/extract_dts_includes.py b/scripts/dts/extract_dts_includes.py index 274d15678aa..56d57e33dec 100755 --- a/scripts/dts/extract_dts_includes.py +++ b/scripts/dts/extract_dts_includes.py @@ -659,8 +659,8 @@ def output_include_lines(fd, fixups): fd.write(" * DO NOT MODIFY\n") fd.write(" */\n") fd.write("\n") - fd.write("#ifndef _DEVICE_TREE_BOARD_H" + "\n") - fd.write("#define _DEVICE_TREE_BOARD_H" + "\n") + fd.write("#ifndef DEVICE_TREE_BOARD_H" + "\n") + fd.write("#define DEVICE_TREE_BOARD_H" + "\n") fd.write("\n") node_keys = sorted(defs.keys()) diff --git a/scripts/gen_kobject_list.py b/scripts/gen_kobject_list.py index 8ec86cda621..e0384c98c67 100755 --- a/scripts/gen_kobject_list.py +++ b/scripts/gen_kobject_list.py @@ -154,8 +154,8 @@ driver_macro_tpl = """ def write_validation_output(fp): - fp.write("#ifndef __DRIVER_VALIDATION_GEN_H__\n") - fp.write("#define __DRIVER_VALIDATION_GEN_H__\n") + fp.write("#ifndef DRIVER_VALIDATION_GEN_H\n") + fp.write("#define DRIVER_VALIDATION_GEN_H\n") fp.write("""#define Z_SYSCALL_DRIVER_GEN(ptr, op, driver_lower_case, driver_upper_case) \\ (Z_SYSCALL_OBJ(ptr, K_OBJ_DRIVER_##driver_upper_case) || \\ @@ -170,7 +170,7 @@ def write_validation_output(fp): "driver_upper": subsystem.upper(), }) - fp.write("#endif /* __DRIVER_VALIDATION_GEN_H__ */\n") + fp.write("#endif /* DRIVER_VALIDATION_GEN_H */\n") def write_kobj_types_output(fp): diff --git a/scripts/gen_syscalls.py b/scripts/gen_syscalls.py index ad90629b9af..e385f9413e0 100755 --- a/scripts/gen_syscalls.py +++ b/scripts/gen_syscalls.py @@ -24,8 +24,8 @@ const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT] = { list_template = """ /* auto-generated by gen_syscalls.py, don't edit */ -#ifndef _ZEPHYR_SYSCALL_LIST_H_ -#define _ZEPHYR_SYSCALL_LIST_H_ +#ifndef ZEPHYR_SYSCALL_LIST_H +#define ZEPHYR_SYSCALL_LIST_H %s @@ -45,7 +45,7 @@ extern "C" { #endif /* _ASMLANGUAGE */ -#endif /* _ZEPHYR_SYSCALL_LIST_H_ */ +#endif /* ZEPHYR_SYSCALL_LIST_H */ """ syscall_template = """