From 26817f989e4de2e76b83c6299cab8b209f923a38 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 20 Jan 2017 12:42:44 +0100 Subject: [PATCH 1/4] boards cpu pkg sys: fix new header guards --- boards/nucleo32-f303/include/board.h | 6 +++--- boards/nucleo32-f303/include/periph_conf.h | 6 +++--- cpu/native/include/netdev2_tap_params.h | 6 +++--- pkg/oonf_api/patches/0001-add-RIOT-support.patch | 4 ++-- pkg/tlsf/patch.txt | 4 ++-- sys/include/bloom.h | 6 +++--- sys/include/ecc/hamming256.h | 4 ++-- sys/include/hashes/sha1.h | 6 +++--- sys/include/hashes/sha256.h | 6 +++--- sys/include/uuid.h | 6 +++--- sys/posix/include/netinet/in.h | 6 +++--- sys/posix/include/sys/socket.h | 4 ++-- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/boards/nucleo32-f303/include/board.h b/boards/nucleo32-f303/include/board.h index 5eed307664f6..9eb9b72b8785 100644 --- a/boards/nucleo32-f303/include/board.h +++ b/boards/nucleo32-f303/include/board.h @@ -18,8 +18,8 @@ * @author Alexandre Abadie */ -#ifndef BOARD_H_ -#define BOARD_H_ +#ifndef BOARD_H +#define BOARD_H #ifdef __cplusplus extern "C" { @@ -47,5 +47,5 @@ void board_init(void); } #endif -#endif /* BOARD_H_ */ +#endif /* BOARD_H */ /** @} */ diff --git a/boards/nucleo32-f303/include/periph_conf.h b/boards/nucleo32-f303/include/periph_conf.h index 955dc2224de3..c7f6b48af63b 100644 --- a/boards/nucleo32-f303/include/periph_conf.h +++ b/boards/nucleo32-f303/include/periph_conf.h @@ -16,8 +16,8 @@ * @author Alexandre Abadie */ -#ifndef PERIPH_CONF_H_ -#define PERIPH_CONF_H_ +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H #include "periph_cpu.h" @@ -152,5 +152,5 @@ static const pwm_conf_t pwm_config[] = { } #endif -#endif /* PERIPH_CONF_H_ */ +#endif /* PERIPH_CONF_H */ /** @} */ diff --git a/cpu/native/include/netdev2_tap_params.h b/cpu/native/include/netdev2_tap_params.h index bde2ec52d987..61b9eff08091 100644 --- a/cpu/native/include/netdev2_tap_params.h +++ b/cpu/native/include/netdev2_tap_params.h @@ -16,8 +16,8 @@ * * @author Martine Lenders */ -#ifndef NETDEV2_TAP_PARAMS_H_ -#define NETDEV2_TAP_PARAMS_H_ +#ifndef NETDEV2_TAP_PARAMS_H +#define NETDEV2_TAP_PARAMS_H #include "netdev2_tap.h" @@ -46,5 +46,5 @@ extern netdev2_tap_params_t netdev2_tap_params[NETDEV2_TAP_MAX]; } #endif -#endif /* NETDEV2_TAP_PARAMS_H_ */ +#endif /* NETDEV2_TAP_PARAMS_H */ /** @} */ diff --git a/pkg/oonf_api/patches/0001-add-RIOT-support.patch b/pkg/oonf_api/patches/0001-add-RIOT-support.patch index e8ec40831b77..018cb7112e99 100644 --- a/pkg/oonf_api/patches/0001-add-RIOT-support.patch +++ b/pkg/oonf_api/patches/0001-add-RIOT-support.patch @@ -238,8 +238,8 @@ index 0000000..9bf6622 + * + */ + -+#ifndef RFC5444_API_CONFIG_H_ -+#define RFC5444_API_CONFIG_H_ ++#ifndef RFC5444_API_CONFIG_H ++#define RFC5444_API_CONFIG_H + +#define DISALLOW_CONSUMER_CONTEXT_DROP false +#define WRITER_STATE_MACHINE true diff --git a/pkg/tlsf/patch.txt b/pkg/tlsf/patch.txt index 64d4d05b100d..b520fb1c59ad 100644 --- a/pkg/tlsf/patch.txt +++ b/pkg/tlsf/patch.txt @@ -63,8 +63,8 @@ index 0000000..2d8bb4d --- /dev/null +++ tlsf-malloc.h @@ -0,0 +1,26 @@ -+#ifndef __TLSF_MALLOC_H -+#define __TLSF_MALLOC_H ++#ifndef TLSF_MALLOC_H ++#define TLSF_MALLOC_H + +#include +#include diff --git a/sys/include/bloom.h b/sys/include/bloom.h index d669cbb49adb..8ff2679611a0 100644 --- a/sys/include/bloom.h +++ b/sys/include/bloom.h @@ -120,8 +120,8 @@ * @author Christian Mehlis */ -#ifndef _BLOOM_FILTER_H -#define _BLOOM_FILTER_H +#ifndef BLOOM_FILTER_H +#define BLOOM_FILTER_H #include #include @@ -233,4 +233,4 @@ bool bloom_check(bloom_t *bloom, const uint8_t *buf, size_t len); #endif /** @} */ -#endif /* _BLOOM_FILTER_H */ +#endif /* BLOOM_FILTER_H */ diff --git a/sys/include/ecc/hamming256.h b/sys/include/ecc/hamming256.h index 5c2cc989186f..f919dfd7ec79 100644 --- a/sys/include/ecc/hamming256.h +++ b/sys/include/ecc/hamming256.h @@ -15,8 +15,8 @@ * @author Lucas Jenß */ -#ifndef _HAMMING256_H -#define _HAMMING256_H +#ifndef HAMMING256_H +#define HAMMING256_H #include diff --git a/sys/include/hashes/sha1.h b/sys/include/hashes/sha1.h index 362f6fefbaca..bfc86b73afd5 100644 --- a/sys/include/hashes/sha1.h +++ b/sys/include/hashes/sha1.h @@ -23,8 +23,8 @@ /* This code is public-domain - it is based on libcrypt * placed in the public domain by Wei Dai and other contributors. */ -#ifndef _SHA1_H -#define _SHA1_H +#ifndef SHA1_H +#define SHA1_H #include @@ -118,5 +118,5 @@ void sha1_final_hmac(sha1_context *ctx, void *digest); } #endif -#endif /* _SHA1_H */ +#endif /* SHA1_H */ /** @} */ diff --git a/sys/include/hashes/sha256.h b/sys/include/hashes/sha256.h index 887d02886587..f67342366226 100644 --- a/sys/include/hashes/sha256.h +++ b/sys/include/hashes/sha256.h @@ -41,8 +41,8 @@ * @author Rene Kijewski */ -#ifndef _SHA256_H -#define _SHA256_H +#ifndef SHA256_H +#define SHA256_H #include @@ -203,4 +203,4 @@ int sha256_chain_verify_element(void *element, #endif /** @} */ -#endif /* _SHA256_H */ +#endif /* SHA256_H */ diff --git a/sys/include/uuid.h b/sys/include/uuid.h index aa6ef59029c9..f813253a2edf 100644 --- a/sys/include/uuid.h +++ b/sys/include/uuid.h @@ -50,8 +50,8 @@ * @author Hauke Petersen */ -#ifndef UUID_H_ -#define UUID_H_ +#ifndef UUID_H +#define UUID_H #include @@ -115,5 +115,5 @@ void uuid_base(void *buf, size_t len); } #endif -#endif /* UUID_H_ */ +#endif /* UUID_H */ /** @} */ diff --git a/sys/posix/include/netinet/in.h b/sys/posix/include/netinet/in.h index b6597c95c5d0..847591fde957 100644 --- a/sys/posix/include/netinet/in.h +++ b/sys/posix/include/netinet/in.h @@ -20,8 +20,8 @@ * * @author Martine Lenders */ -#ifndef _NETINET_IN_H -#define _NETINET_IN_H +#ifndef NETINET_IN_H +#define NETINET_IN_H #include #include @@ -271,4 +271,4 @@ extern const struct in6_addr in6addr_loopback; /** * @} */ -#endif /* _NETINET_IN_H */ +#endif /* NETINET_IN_H */ diff --git a/sys/posix/include/sys/socket.h b/sys/posix/include/sys/socket.h index 2624d5ce4bff..cb54509e53a6 100644 --- a/sys/posix/include/sys/socket.h +++ b/sys/posix/include/sys/socket.h @@ -26,8 +26,8 @@ * * @author Martine Lenders */ -#ifndef _SYS_SOCKET_H -#define _SYS_SOCKET_H +#ifndef SYS_SOCKET_H +#define SYS_SOCKET_H #ifdef CPU_NATIVE /* Ignore Linux definitions in native */ From 319a0fa2458a804670ea194e53434ddc55bb874a Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 20 Jan 2017 13:56:10 +0100 Subject: [PATCH 2/4] dist tools: script to check correct header guards --- dist/tools/headerguards/check.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 dist/tools/headerguards/check.sh diff --git a/dist/tools/headerguards/check.sh b/dist/tools/headerguards/check.sh new file mode 100755 index 000000000000..a74be48c7adc --- /dev/null +++ b/dist/tools/headerguards/check.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Copyright 2017 Oliver Hahm +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +# customizable +DIRS="core drivers sys" + +# prepare +EXIT_CODE=0 + +# check files +if FILES=$(git grep -lE 'ifndef\ +(_.*|.*_H_$)' ${DIRS}) +then + EXIT_CODE=1 + for LINE in ${FILES} + do + echo "files with invalid header guard (leading or trailing underscore): ${LINE}" + done +fi + +exit ${EXIT_CODE} From 68f93f4d5801a13332d209c2e135e9a3c5a95ed3 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 20 Jan 2017 13:57:34 +0100 Subject: [PATCH 3/4] dist tools: added header guard checker to CI --- dist/tools/ci/build_and_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/tools/ci/build_and_test.sh b/dist/tools/ci/build_and_test.sh index 5f3e6a210af9..4a6b3658a1d7 100755 --- a/dist/tools/ci/build_and_test.sh +++ b/dist/tools/ci/build_and_test.sh @@ -86,6 +86,7 @@ then run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=AC run ./dist/tools/doccheck/check.sh ${CI_BASE_BRANCH} run ./dist/tools/externc/check.sh ${CI_BASE_BRANCH} + run ./dist/tools/headerguards/check.sh # TODO: # Remove all but `${CI_BASE_BRANCH}` parameters to cppcheck (and remove second From 7486ea924de0a9b0ce458f5582ecd2b880ee3586 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 20 Jan 2017 14:09:57 +0100 Subject: [PATCH 4/4] SQUASH ME: minor script update --- dist/tools/headerguards/check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/tools/headerguards/check.sh b/dist/tools/headerguards/check.sh index a74be48c7adc..7a4afdb1d77b 100755 --- a/dist/tools/headerguards/check.sh +++ b/dist/tools/headerguards/check.sh @@ -7,13 +7,13 @@ # directory for more details. # customizable -DIRS="core drivers sys" +DIRS="core drivers pkg sys" # prepare EXIT_CODE=0 # check files -if FILES=$(git grep -lE 'ifndef\ +(_.*|.*_H_$)' ${DIRS}) +if FILES=$(git grep -lE 'ifndef\ +(_.*_H$|.*_H_$)' ${DIRS}) then EXIT_CODE=1 for LINE in ${FILES}