From e44461151fe0f1491bdc5803beb3c07536677acb Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Wed, 8 Jan 2020 13:37:46 -0300 Subject: [PATCH] [build] detect undefined macros to avoid misconfigurations (#4300) --- configure.ac | 74 +++++++++++++++---- examples/common-switches.mk | 2 + examples/platforms/cc1352/radio.c | 1 + examples/platforms/cc2650/alarm.c | 2 + examples/platforms/cc2650/diag.c | 1 + examples/platforms/cc2650/radio.c | 1 + examples/platforms/cc2652/radio.c | 1 + examples/platforms/efr32mg12/Makefile.am | 4 + .../efr32mg12/openthread-core-efr32-config.h | 4 +- examples/platforms/efr32mg21/Makefile.am | 4 + .../efr32mg21/openthread-core-efr32-config.h | 2 +- examples/platforms/kw41z/Makefile.am | 4 + .../platforms/nrf528xx/nrf52811/Makefile.am | 4 + .../platforms/nrf528xx/nrf52833/Makefile.am | 4 + .../platforms/nrf528xx/nrf52840/Makefile.am | 4 + examples/platforms/qpg6095/logging.c | 2 + examples/platforms/qpg6095/settings.cpp | 1 - examples/platforms/samr21/Makefile.am | 4 + include/openthread/platform/debug_uart.h | 4 +- src/cli/Makefile.am | 8 ++ src/cli/cli.cpp | 2 +- src/cli/cli_coap_secure.hpp | 4 + src/cli/cli_config.h | 10 +++ src/core/Makefile.am | 6 ++ src/core/common/encoding.hpp | 4 + src/core/common/random_manager.cpp | 12 +-- src/core/common/random_manager.hpp | 8 +- src/core/config/mac.h | 4 +- .../config/openthread-core-default-config.h | 14 +++- src/core/mac/mac_frame.hpp | 2 +- src/core/openthread-core-config.h | 2 + src/core/thread/mle.cpp | 2 +- src/ncp/Makefile.am | 6 ++ src/ncp/ncp_config.h | 10 +++ src/ncp/ncp_uart.hpp | 12 +-- src/ncp/spinel.c | 16 ++++ third_party/NordicSemiconductor/Makefile.am | 4 + third_party/jlink/Makefile.am | 4 + third_party/silabs/.gitignore | 1 + third_party/silabs/Makefile.am | 4 + 40 files changed, 218 insertions(+), 40 deletions(-) create mode 100644 third_party/silabs/.gitignore diff --git a/configure.ac b/configure.ac index 2f26ad354..d9a8c19e2 100644 --- a/configure.ac +++ b/configure.ac @@ -222,6 +222,11 @@ AC_PROG_LN_S AC_PATH_PROG(CMP, cmp) +# Check for and initialize libtool + +LT_INIT +AC_PROG_LIBTOOL + # # Checks for specific compiler characteristics # @@ -232,8 +237,8 @@ AC_PATH_PROG(CMP, cmp) # -Wall CC, CXX # -PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Werror -std=c99 -pedantic-errors -Wno-gnu-zero-variadic-macro-arguments" -PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Werror -std=gnu++98 -Wno-c++14-compat -fno-exceptions" +PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Wundef -Werror -Wno-error=undef -std=c99 -pedantic-errors" +PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Wundef -Werror -Wno-error=undef -std=gnu++98 -Wno-c++14-compat -fno-exceptions" AC_CACHE_CHECK([whether $CC is Clang], [nl_cv_clang], @@ -250,17 +255,60 @@ AC_CACHE_CHECK([whether $CC is Clang], ]) if test "${nl_cv_clang}" = "yes"; then - PROSPECTIVE_CFLAGS="${PROSPECTIVE_CFLAGS} -Wconversion" + PROSPECTIVE_CFLAGS="${PROSPECTIVE_CFLAGS} -Wconversion -Wno-gnu-zero-variadic-macro-arguments" PROSPECTIVE_CXXFLAGS="${PROSPECTIVE_CXXFLAGS} -Wconversion" fi -AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS}) -AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS}) +function convert_warning_flags_to_positive() { + flags_to_check="" + warning_flag_backup="" + for option in ${1}; do + case "$option" + in + -Wno-*) + flags_to_check="${flags_to_check} -W${option##-Wno-}" + warning_flag_backup="${warning_flag_backup} ${option##-Wno-}";; + *) + flags_to_check="${flags_to_check} ${option}";; + esac + done +} -# Check for and initialize libtool +function restore_negative_form_of_warning_flags() { + final_flags=${1} + for positive_option in ${warning_flag_backup}; do + final_flags=$(echo $ECHO_N $final_flags | $SED "s|-W${positive_option}|-Wno-${positive_option}|g") + done + unset flags_to_check + unset warning_flag_backup +} -LT_INIT -AC_PROG_LIBTOOL +function check_prospective_CFLAGS() { + if test "${nl_cv_clang}" = "yes"; then + AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS}) + else + convert_warning_flags_to_positive "${PROSPECTIVE_CFLAGS}" + AX_CHECK_COMPILER_OPTIONS([C], ${flags_to_check}) + restore_negative_form_of_warning_flags "${CFLAGS}" + CFLAGS=${final_flags} + unset final_flags + fi +} + +function check_prospective_CXXFLAGS() { + if test "${nl_cv_clang}" = "yes"; then + AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS}) + else + convert_warning_flags_to_positive "${PROSPECTIVE_CXXFLAGS}" + AX_CHECK_COMPILER_OPTIONS([C++], ${flags_to_check}) + restore_negative_form_of_warning_flags "${CXXFLAGS}" + CXXFLAGS=${final_flags} + unset final_flags + fi +} + +check_prospective_CFLAGS +check_prospective_CXXFLAGS # Disable building shared libraries by default (can be enabled with --enable-shared) @@ -322,7 +370,7 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_FUZZ_TARGETS], [test "${enable_fuzz_targets}" if test "${enable_fuzz_targets}" = "no" ; then PROSPECTIVE_CXXFLAGS="-fno-rtti" - AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS}) + check_prospective_CXXFLAGS fi # Address Sanitizer @@ -351,11 +399,11 @@ AM_CONDITIONAL([OPENTHREAD_WITH_ADDRESS_SANITIZER], [test "${enable_address_sani if test "${enable_address_sanitizer}" = "yes" ; then PROSPECTIVE_CFLAGS="-fsanitize=address" + PROSPECTIVE_CXXFLAGS="-fsanitize=address" # Check if the compilers support address sanitizer - AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS}) - AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CFLAGS}) - + check_prospective_CFLAGS + check_prospective_CXXFLAGS fi # @@ -816,7 +864,7 @@ AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52840], [test "${with_examples}" = "nrf5 AM_CONDITIONAL([OPENTHREAD_EXAMPLES_QPG6095], [test "${with_examples}" = "qpg6095"]) AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SAMR21], [test "${with_examples}" = "samr21"]) -AM_COND_IF([OPENTHREAD_EXAMPLES_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_POSIX=1") +AM_COND_IF([OPENTHREAD_EXAMPLES_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_POSIX=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_POSIX=0") AC_MSG_CHECKING([whether to enable examples]) AC_MSG_RESULT(${with_examples}) diff --git a/examples/common-switches.mk b/examples/common-switches.mk index f5fb281a3..aa668a6eb 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -225,6 +225,8 @@ endif ifeq ($(SETTINGS_RAM),1) COMMONCFLAGS += -DOPENTHREAD_SETTINGS_RAM=1 +else +COMMONCFLAGS += -DOPENTHREAD_SETTINGS_RAM=0 endif ifeq ($(FULL_LOGS),1) diff --git a/examples/platforms/cc1352/radio.c b/examples/platforms/cc1352/radio.c index 19175d968..b401fa8a6 100644 --- a/examples/platforms/cc1352/radio.c +++ b/examples/platforms/cc1352/radio.c @@ -32,6 +32,7 @@ * */ +#include "openthread-core-config.h" #include #include diff --git a/examples/platforms/cc2650/alarm.c b/examples/platforms/cc2650/alarm.c index d1ae1bf49..919787aa6 100644 --- a/examples/platforms/cc2650/alarm.c +++ b/examples/platforms/cc2650/alarm.c @@ -26,6 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "openthread-core-config.h" + #include #include #include diff --git a/examples/platforms/cc2650/diag.c b/examples/platforms/cc2650/diag.c index 7d0a7294c..95973df78 100644 --- a/examples/platforms/cc2650/diag.c +++ b/examples/platforms/cc2650/diag.c @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "openthread-core-config.h" #include #include diff --git a/examples/platforms/cc2650/radio.c b/examples/platforms/cc2650/radio.c index 0da9cf4f2..6d3628dc5 100644 --- a/examples/platforms/cc2650/radio.c +++ b/examples/platforms/cc2650/radio.c @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "openthread-core-config.h" #include #include "cc2650_radio.h" diff --git a/examples/platforms/cc2652/radio.c b/examples/platforms/cc2652/radio.c index 68550b1ed..f6b471221 100644 --- a/examples/platforms/cc2652/radio.c +++ b/examples/platforms/cc2652/radio.c @@ -32,6 +32,7 @@ * */ +#include "openthread-core-config.h" #include #include diff --git a/examples/platforms/efr32mg12/Makefile.am b/examples/platforms/efr32mg12/Makefile.am index 023ff760a..5dcc6ad68 100644 --- a/examples/platforms/efr32mg12/Makefile.am +++ b/examples/platforms/efr32mg12/Makefile.am @@ -38,6 +38,10 @@ override CXXFLAGS := $(filter-out -Wconversion,$(CXXF override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for rail +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + EFR32_BOARD_DIR = $(shell echo $(BOARD) | tr A-Z a-z) EFR32MG_SDK_SRCDIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v2.6 diff --git a/examples/platforms/efr32mg12/openthread-core-efr32-config.h b/examples/platforms/efr32mg12/openthread-core-efr32-config.h index c08a29517..65e1aed7e 100644 --- a/examples/platforms/efr32mg12/openthread-core-efr32-config.h +++ b/examples/platforms/efr32mg12/openthread-core-efr32-config.h @@ -53,7 +53,7 @@ * Define to 1 if you want to enable physical layer to support OQPSK modulation in 915MHz band. * */ -#ifdef RADIO_CONFIG_915MHZ_OQPSK_SUPPORT +#if RADIO_CONFIG_915MHZ_OQPSK_SUPPORT #define OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT 1 #else #define OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT 0 @@ -65,7 +65,7 @@ * Define to 1 if you want to enable physical layer to support OQPSK modulation in 2.4GHz band. * */ -#ifdef RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT +#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT #define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 1 #else #define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 0 diff --git a/examples/platforms/efr32mg21/Makefile.am b/examples/platforms/efr32mg21/Makefile.am index 7283d89d2..09aa68e12 100644 --- a/examples/platforms/efr32mg21/Makefile.am +++ b/examples/platforms/efr32mg21/Makefile.am @@ -38,6 +38,10 @@ override CXXFLAGS := $(filter-out -Wconversion,$(CXXF override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for rail +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + EFR32_BOARD_DIR = $(shell echo $(BOARD) | tr A-Z a-z) EFR32MG_SDK_SRCDIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v2.6 diff --git a/examples/platforms/efr32mg21/openthread-core-efr32-config.h b/examples/platforms/efr32mg21/openthread-core-efr32-config.h index 1cc95180a..95bead195 100644 --- a/examples/platforms/efr32mg21/openthread-core-efr32-config.h +++ b/examples/platforms/efr32mg21/openthread-core-efr32-config.h @@ -62,7 +62,7 @@ * Define to 1 if you want to enable physical layer to support OQPSK modulation in 2.4GHz band. * */ -#ifdef RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT +#if RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT #define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 1 #else #define OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT 0 diff --git a/examples/platforms/kw41z/Makefile.am b/examples/platforms/kw41z/Makefile.am index 4f3f7dece..33d7ef426 100644 --- a/examples/platforms/kw41z/Makefile.am +++ b/examples/platforms/kw41z/Makefile.am @@ -30,6 +30,10 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am lib_LIBRARIES = libopenthread-kw41z.a +# Do not enable -Wundef for this platform +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + libopenthread_kw41z_a_CPPFLAGS = \ -DCPU_MKW41Z512VHT4 \ -I$(top_srcdir)/include \ diff --git a/examples/platforms/nrf528xx/nrf52811/Makefile.am b/examples/platforms/nrf528xx/nrf52811/Makefile.am index 5136f2318..8011fc6d0 100644 --- a/examples/platforms/nrf528xx/nrf52811/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52811/Makefile.am @@ -37,6 +37,10 @@ lib_LIBRARIES override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for nRF52811 driver library +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + COMMONCPPFLAGS = \ -DCONFIG_GPIO_AS_PINRESET \ -DNRF52811_XXAA \ diff --git a/examples/platforms/nrf528xx/nrf52833/Makefile.am b/examples/platforms/nrf528xx/nrf52833/Makefile.am index 0b2103e1f..ee34bdb69 100644 --- a/examples/platforms/nrf528xx/nrf52833/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52833/Makefile.am @@ -38,6 +38,10 @@ lib_LIBRARIES override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for nRF52833 driver library +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + COMMONCPPFLAGS = \ -DCONFIG_GPIO_AS_PINRESET \ -DNRF52833_XXAA \ diff --git a/examples/platforms/nrf528xx/nrf52840/Makefile.am b/examples/platforms/nrf528xx/nrf52840/Makefile.am index e558e00e7..6a06149f7 100644 --- a/examples/platforms/nrf528xx/nrf52840/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52840/Makefile.am @@ -38,6 +38,10 @@ lib_LIBRARIES override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for nRF52840 driver library +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + COMMONCPPFLAGS = \ -DCONFIG_GPIO_AS_PINRESET \ -DNRF52840_XXAA \ diff --git a/examples/platforms/qpg6095/logging.c b/examples/platforms/qpg6095/logging.c index 264f6f5fe..de5ab3f96 100644 --- a/examples/platforms/qpg6095/logging.c +++ b/examples/platforms/qpg6095/logging.c @@ -26,6 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "openthread-core-config.h" + #include "platform_qorvo.h" #include diff --git a/examples/platforms/qpg6095/settings.cpp b/examples/platforms/qpg6095/settings.cpp index 500e9929e..f4e410888 100644 --- a/examples/platforms/qpg6095/settings.cpp +++ b/examples/platforms/qpg6095/settings.cpp @@ -35,7 +35,6 @@ #include #include -#include "common/settings.hpp" #include "openthread/platform/settings.h" #include diff --git a/examples/platforms/samr21/Makefile.am b/examples/platforms/samr21/Makefile.am index 946af886c..e5a21ac7a 100644 --- a/examples/platforms/samr21/Makefile.am +++ b/examples/platforms/samr21/Makefile.am @@ -33,6 +33,10 @@ lib_LIBRARIES = libopenthread-samr21.a override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for this platform +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + libopenthread_samr21_a_CPPFLAGS = \ -D ARM_MATH_CM0PLUS=true \ -D PHY_AT86RF233 \ diff --git a/include/openthread/platform/debug_uart.h b/include/openthread/platform/debug_uart.h index 237f8da8e..9a4f8643b 100644 --- a/include/openthread/platform/debug_uart.h +++ b/include/openthread/platform/debug_uart.h @@ -56,7 +56,7 @@ * intended to be present, or used in production system. */ -#if __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -188,7 +188,7 @@ otError otPlatDebugUart_logfile(const char *filename); * */ -#if __cplusplus +#ifdef __cplusplus } // extern "C" #endif diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index a35b0c0cb..a39cebf8c 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -129,15 +129,23 @@ if OPENTHREAD_POSIX CPPFLAGS_COMMON += \ -DOPENTHREAD_POSIX=1 \ $(NULL) +else +CPPFLAGS_COMMON += \ + -DOPENTHREAD_POSIX=0 \ + $(NULL) endif libopenthread_cli_mtd_a_CPPFLAGS = \ -DOPENTHREAD_MTD=1 \ + -DOPENTHREAD_FTD=0 \ + -DOPENTHREAD_RADIO=0 \ $(CPPFLAGS_COMMON) \ $(NULL) libopenthread_cli_ftd_a_CPPFLAGS = \ + -DOPENTHREAD_MTD=0 \ -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_RADIO=0 \ $(CPPFLAGS_COMMON) \ $(NULL) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 4781ac796..b5c2160ca 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -3561,7 +3561,7 @@ otError Interpreter::ProcessMacRetries(int argc, char *argv[]) otLinkSetMaxFrameRetriesDirect(mInstance, static_cast(value)); } } -#ifdef OPENTHREAD_FTD +#if OPENTHREAD_FTD else if (strcmp(argv[0], "indirect") == 0) { if (argc == 1) diff --git a/src/cli/cli_coap_secure.hpp b/src/cli/cli_coap_secure.hpp index c6ecec7d0..6d6b41436 100644 --- a/src/cli/cli_coap_secure.hpp +++ b/src/cli/cli_coap_secure.hpp @@ -41,6 +41,10 @@ #include "coap/coap_message.hpp" #include "coap/coap_secure.hpp" +#ifndef CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER +#define CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER 0 +#endif + namespace ot { namespace Cli { diff --git a/src/cli/cli_config.h b/src/cli/cli_config.h index 2bb911134..cd77e2b7c 100644 --- a/src/cli/cli_config.h +++ b/src/cli/cli_config.h @@ -65,4 +65,14 @@ #define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 1024 #endif +/** + * @def OPENTHREAD_CONFIG_UART_CLI_RAW + * + * TODO: complete. + * + */ +#ifndef OPENTHREAD_CONFIG_UART_CLI_RAW +#define OPENTHREAD_CONFIG_UART_CLI_RAW 0 +#endif + #endif // CONFIG_CLI_H_ diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 2ec7ae824..8bca8e319 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -49,17 +49,23 @@ CPPFLAGS_COMMON = \ libopenthread_radio_a_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ + -DOPENTHREAD_MTD=0 \ + -DOPENTHREAD_FTD=0 \ -DOPENTHREAD_RADIO=1 \ $(NULL) libopenthread_ftd_a_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ + -DOPENTHREAD_MTD=0 \ -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_RADIO=0 \ $(NULL) libopenthread_mtd_a_CPPFLAGS = \ $(CPPFLAGS_COMMON) \ -DOPENTHREAD_MTD=1 \ + -DOPENTHREAD_FTD=0 \ + -DOPENTHREAD_RADIO=0 \ $(NULL) #------------------------------------------------------ diff --git a/src/core/common/encoding.hpp b/src/core/common/encoding.hpp index 550246d5e..0d4ba72cb 100644 --- a/src/core/common/encoding.hpp +++ b/src/core/common/encoding.hpp @@ -36,6 +36,10 @@ #include "openthread-core-config.h" +#ifndef BYTE_ORDER_BIG_ENDIAN +#define BYTE_ORDER_BIG_ENDIAN 0 +#endif + #include #include diff --git a/src/core/common/random_manager.cpp b/src/core/common/random_manager.cpp index d599224d1..128fe6aa1 100644 --- a/src/core/common/random_manager.cpp +++ b/src/core/common/random_manager.cpp @@ -35,7 +35,7 @@ #include -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO #include #endif @@ -49,7 +49,7 @@ namespace ot { uint16_t RandomManager::sInitCount = 0; RandomManager::NonCryptoPrng RandomManager::sPrng; -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO RandomManager::Entropy RandomManager::sEntropy; RandomManager::CryptoCtrDrbg RandomManager::sCtrDrbg; #endif @@ -63,7 +63,7 @@ RandomManager::RandomManager(void) VerifyOrExit(sInitCount == 0); -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO sEntropy.Init(); sCtrDrbg.Init(); @@ -87,7 +87,7 @@ RandomManager::~RandomManager(void) sInitCount--; VerifyOrExit(sInitCount == 0); -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO sCtrDrbg.Deinit(); sEntropy.Deinit(); #endif @@ -141,7 +141,7 @@ uint32_t RandomManager::NonCryptoPrng::GetNext(void) return mlcg; } -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO //------------------------------------------------------------------- // Entropy @@ -203,6 +203,6 @@ otError RandomManager::CryptoCtrDrbg::FillBuffer(uint8_t *aBuffer, uint16_t aSiz mbedtls_ctr_drbg_random(&mCtrDrbg, static_cast(aBuffer), static_cast(aSize))); } -#endif // #ifndef OPENTHREAD_RADIO +#endif // #if !OPENTHREAD_RADIO } // namespace ot diff --git a/src/core/common/random_manager.hpp b/src/core/common/random_manager.hpp index d9cfe0ef6..ea11bdb4c 100644 --- a/src/core/common/random_manager.hpp +++ b/src/core/common/random_manager.hpp @@ -39,7 +39,7 @@ #include #include -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO #include #include #endif @@ -78,7 +78,7 @@ public: */ static uint32_t NonCryptoGetUint32(void); -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO /** * This static method returns the initialized mbedtls_entropy_context. * @@ -117,7 +117,7 @@ private: uint32_t mState; }; -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO class Entropy { public: @@ -150,7 +150,7 @@ private: static uint16_t sInitCount; static NonCryptoPrng sPrng; -#ifndef OPENTHREAD_RADIO +#if !OPENTHREAD_RADIO static Entropy sEntropy; static CryptoCtrDrbg sCtrDrbg; #endif diff --git a/src/core/config/mac.h b/src/core/config/mac.h index abc9ba001..2503d65bf 100644 --- a/src/core/config/mac.h +++ b/src/core/config/mac.h @@ -35,6 +35,8 @@ #ifndef CONFIG_MAC_H_ #define CONFIG_MAC_H_ +#include "config/time_sync.h" + /** * @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT * @@ -198,7 +200,7 @@ * */ #ifndef OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION -#define OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION kProtocolVersion +#define OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION OPENTHREAD_THREAD_VERSION #endif /** diff --git a/src/core/config/openthread-core-default-config.h b/src/core/config/openthread-core-default-config.h index a5dc9db2c..3accdb4a9 100644 --- a/src/core/config/openthread-core-default-config.h +++ b/src/core/config/openthread-core-default-config.h @@ -6,7 +6,7 @@ * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - >* 2. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the @@ -35,6 +35,8 @@ #ifndef OPENTHREAD_CORE_DEFAULT_CONFIG_H_ #define OPENTHREAD_CORE_DEFAULT_CONFIG_H_ +#include "config/coap.h" + /** * @def OPENTHREAD_CONFIG_STACK_VENDOR_OUI * @@ -264,6 +266,16 @@ #define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE_NO_DTLS 384 #endif +/** + * @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE + * + * Enable the external heap. + * + */ +#ifndef OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE +#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 +#endif + /** * @def OPENTHREAD_CONFIG_DTLS_APPLICATION_DATA_MAX_LENGTH * diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index 9b16cd1d2..5259dc14d 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -1287,7 +1287,7 @@ public: { mFlags |= kJoiningFlag; -#if OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION != kProtocolVersion +#if OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION != 2 // check against kProtocolVersion mFlags &= ~kVersionMask; mFlags |= OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION << kVersionOffset; #endif diff --git a/src/core/openthread-core-config.h b/src/core/openthread-core-config.h index 80a46fd03..284718768 100644 --- a/src/core/openthread-core-config.h +++ b/src/core/openthread-core-config.h @@ -73,6 +73,8 @@ #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \ OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE #define OPENTHREAD_CONFIG_DTLS_ENABLE 1 +#else +#define OPENTHREAD_CONFIG_DTLS_ENABLE 0 #endif #undef OPENTHREAD_CORE_CONFIG_H_IN diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 2271973d6..4285a04e2 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -972,7 +972,7 @@ void Mle::SetRloc16(uint16_t aRloc16) // mesh-local 16 mMeshLocal16.GetAddress().mFields.m16[7] = HostSwap16(aRloc16); Get().AddUnicastAddress(mMeshLocal16); -#ifdef OPENTHREAD_FTD +#if OPENTHREAD_FTD Get().RestartAddressQueries(); #endif } diff --git a/src/ncp/Makefile.am b/src/ncp/Makefile.am index 0831f8228..24e301b29 100644 --- a/src/ncp/Makefile.am +++ b/src/ncp/Makefile.am @@ -59,17 +59,23 @@ COMMON_CPPFLAGS = \ $(NULL) libopenthread_ncp_mtd_a_CPPFLAGS = \ + -DOPENTHREAD_RADIO=0 \ + -DOPENTHREAD_FTD=0 \ -DOPENTHREAD_MTD=1 \ $(COMMON_CPPFLAGS) \ $(NULL) libopenthread_ncp_ftd_a_CPPFLAGS = \ + -DOPENTHREAD_RADIO=0 \ -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_MTD=0 \ $(COMMON_CPPFLAGS) \ $(NULL) libopenthread_rcp_a_CPPFLAGS = \ -DOPENTHREAD_RADIO=1 \ + -DOPENTHREAD_FTD=0 \ + -DOPENTHREAD_MTD=0 \ $(COMMON_CPPFLAGS) \ $(NULL) diff --git a/src/ncp/ncp_config.h b/src/ncp/ncp_config.h index 284923f6b..954454944 100644 --- a/src/ncp/ncp_config.h +++ b/src/ncp/ncp_config.h @@ -175,4 +175,14 @@ #define OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL 0 #endif +/** + * @def OPENTHREAD_ENABLE_NCP_VENDOR_HOOK + * + * TODO: complete. + * + */ +#ifndef OPENTHREAD_ENABLE_NCP_VENDOR_HOOK +#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0 +#endif + #endif // CONFIG_NCP_H_ diff --git a/src/ncp/ncp_uart.hpp b/src/ncp/ncp_uart.hpp index e652c79de..8e61e7222 100644 --- a/src/ncp/ncp_uart.hpp +++ b/src/ncp/ncp_uart.hpp @@ -38,9 +38,9 @@ #include "ncp/hdlc.hpp" #include "ncp/ncp_base.hpp" -#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER #include "spinel_encrypter.hpp" -#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER namespace ot { namespace Ncp { @@ -85,7 +85,7 @@ private: kFinalizingFrame, // Finalizing a frame. }; -#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER /** * Wraps NcpFrameBuffer allowing to read data through spinel encrypter. * Creates additional buffers to allow transforming of the whole spinel frames. @@ -112,7 +112,7 @@ private: size_t mDataBufferReadIndex; size_t mOutputDataLength; }; -#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER void EncodeAndSendToUart(void); void HandleFrame(otError aError); @@ -136,9 +136,9 @@ private: bool mUartSendImmediate; Tasklet mUartSendTask; -#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER NcpFrameBufferEncrypterReader mTxFrameBufferEncrypterReader; -#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER +#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER }; } // namespace Ncp diff --git a/src/ncp/spinel.c b/src/ncp/spinel.c index 0698881de..16e55ace6 100644 --- a/src/ncp/spinel.c +++ b/src/ncp/spinel.c @@ -84,6 +84,22 @@ #define ENOMEM 1 #endif +#ifndef SPINEL_PLATFORM_SHOULD_LOG_ASSERTS +#define SPINEL_PLATFORM_SHOULD_LOG_ASSERTS 0 +#endif + +#ifndef SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR +#define SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR 0 +#endif + +#ifndef SPINEL_PLATFORM_DOESNT_IMPLEMENT_FPRINTF +#define SPINEL_PLATFORM_DOESNT_IMPLEMENT_FPRINTF 0 +#endif + +#ifndef SPINEL_SELF_TEST +#define SPINEL_SELF_TEST 0 +#endif + #if defined(errno) && SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR #error "SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR is set but errno is already defined." #endif diff --git a/third_party/NordicSemiconductor/Makefile.am b/third_party/NordicSemiconductor/Makefile.am index c3760ba99..bd0307b6e 100644 --- a/third_party/NordicSemiconductor/Makefile.am +++ b/third_party/NordicSemiconductor/Makefile.am @@ -55,6 +55,10 @@ endif override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS)) override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS)) +# Do not enable -Wundef for Nordic Semiconductor driver library +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + COMMONCPPFLAGS = \ -DCONFIG_GPIO_AS_PINRESET \ -DENABLE_FEM=1 \ diff --git a/third_party/jlink/Makefile.am b/third_party/jlink/Makefile.am index 5b5f35122..16e3aa664 100644 --- a/third_party/jlink/Makefile.am +++ b/third_party/jlink/Makefile.am @@ -28,6 +28,10 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am +# Do not enable -Wundef for jlink library +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + lib_LIBRARIES = libjlinkrtt.a libjlinkrtt_a_CPPFLAGS = \ diff --git a/third_party/silabs/.gitignore b/third_party/silabs/.gitignore new file mode 100644 index 000000000..2ea65591b --- /dev/null +++ b/third_party/silabs/.gitignore @@ -0,0 +1 @@ +gecko_sdk_suite diff --git a/third_party/silabs/Makefile.am b/third_party/silabs/Makefile.am index 627e0cbc3..754f8a4d8 100644 --- a/third_party/silabs/Makefile.am +++ b/third_party/silabs/Makefile.am @@ -52,6 +52,10 @@ override CXXFLAGS := $(filter-out -pedantic-errors,$( override CFLAGS := $(filter-out -Wshadow,$(CFLAGS)) override CXXFLAGS := $(filter-out -Wshadow,$(CXXFLAGS)) +# Do not enable -Wundef for Silicon Labs SDK sources +override CFLAGS := $(filter-out -Wundef,$(CFLAGS)) +override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS)) + EFR32_BOARD_DIR = $(shell echo $(BOARD) | tr A-Z a-z) EFR32MG_SDK_SRCDIR = $(top_srcdir)/third_party/silabs/gecko_sdk_suite/v2.6