Skip to content

Commit 9dcbbf7

Browse files
s07641069restyled-commitsDamian-Nordic
authored
[Telink] Enable -Wundef by default on Zephyr platform (#29613)
* [Telink] Enable -Wundef by default on Zephyr platform * [Telink] Fix builds * [Telink] Fix builds * Restyled by clang-format * [Telink] Fix builds * [Telink] Fix builds * [Telink] add defines * [Telink] add defines * [Telink] add defines * [Telink] clean code * [Telink] clean code * [Telink] clean code * [Telink] fix builds * [Telink] clean code * [Telink] fix builds * [Telink] fix builds * [Telink} Fix builds * [Telink] Fix builds * [Telink] fix builds * Clean nrfconnect config --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Damian Krolik <damian.krolik@nordicsemi.no>
1 parent 58875c3 commit 9dcbbf7

14 files changed

+59
-36
lines changed

build/config/compiler/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ config("strict_warnings") {
258258
# to be more fine-grained than current_os, but it's not clear that
259259
# we can access that here.
260260
if (current_os != "freertos" && current_os != "mbed" &&
261-
current_os != "zephyr" &&
262261
# cmsis-rtos is OpenIOT
263262
current_os != "cmsis-rtos" &&
264263
# cyw30739 is one of the Infineon builds

src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ CHIP_ERROR GenericPlatformManagerImpl_Zephyr<ImplClass>::_StopEventLoopTask(void
122122
template <class ImplClass>
123123
void GenericPlatformManagerImpl_Zephyr<ImplClass>::_Shutdown(void)
124124
{
125-
#if CONFIG_REBOOT
125+
#ifdef CONFIG_REBOOT
126126
sys_reboot(SYS_REBOOT_WARM);
127127
#else
128128
// NB: When this is implemented, |mInitialized| can be removed.

src/platform/Zephyr/PlatformManagerImpl.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
* for Zephyr platforms.
2222
*/
2323

24-
#if !CONFIG_NORDIC_SECURITY_BACKEND
24+
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND)
2525
#include <crypto/CHIPCryptoPAL.h> // nogncheck
26-
#endif // !CONFIG_NORDIC_SECURITY_BACKEND
26+
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND)
2727

2828
#include <platform/internal/CHIPDeviceLayerInternal.h>
2929

@@ -45,7 +45,7 @@ PlatformManagerImpl PlatformManagerImpl::sInstance{ sChipThreadStack };
4545

4646
static k_timer sOperationalHoursSavingTimer;
4747

48-
#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
48+
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
4949
static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen)
5050
{
5151
const struct device * entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));
@@ -71,7 +71,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s
7171

7272
return ret;
7373
}
74-
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
74+
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
7575

7676
void PlatformManagerImpl::OperationalHoursSavingTimerEventHandler(k_timer * timer)
7777
{
@@ -108,20 +108,20 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
108108
{
109109
CHIP_ERROR err;
110110

111-
#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
111+
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
112112
// Minimum required from source before entropy is released ( with mbedtls_entropy_func() ) (in bytes)
113113
const size_t kThreshold = 16;
114-
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
114+
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
115115

116116
// Initialize the configuration system.
117117
err = Internal::ZephyrConfig::Init();
118118
SuccessOrExit(err);
119119

120-
#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
120+
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
121121
// Add entropy source based on Zephyr entropy driver
122122
err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, kThreshold);
123123
SuccessOrExit(err);
124-
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
124+
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
125125

126126
// Call _InitChipStack() on the generic implementation base class to finish the initialization process.
127127
err = Internal::GenericPlatformManagerImpl_Zephyr<PlatformManagerImpl>::_InitChipStack();

src/platform/Zephyr/ThreadStackManagerImpl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#include <zephyr/net/openthread.h>
3030

3131
#include <openthread/thread.h>
32-
#if !CONFIG_SOC_SERIES_RISCV_TELINK_B9X
32+
#if !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X)
3333
#include <platform/Zephyr/BLEManagerImpl.h>
34-
#endif // !CONFIG_SOC_SERIES_RISCV_TELINK_B9X
34+
#endif // !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X)
3535

3636
#include <lib/support/logging/CHIPLogging.h>
3737

src/platform/nrfconnect/CHIPDevicePlatformConfig.h

+17-5
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,27 @@
8787
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
8888
#endif
8989

90+
#ifdef CONFIG_NET_L2_OPENTHREAD
9091
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
92+
#else
93+
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
94+
#endif
9195

96+
#ifdef CONFIG_WIFI_NRF700X
9297
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI CONFIG_WIFI_NRF700X
93-
94-
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
9598
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
9699
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
97100
#else
101+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
98102
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
99103
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
100104
#endif
101105

106+
#ifdef CONFIG_BT
102107
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT
108+
#else
109+
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
110+
#endif
103111

104112
// ========== Platform-specific Configuration =========
105113

@@ -126,6 +134,8 @@
126134
#if !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC)
127135
/// Use mallinfo() to obtain the heap usage statistics exposed by SoftwareDiagnostics cluster attributes.
128136
#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 1
137+
#else
138+
#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 0
129139
#endif // !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC)
130140
#endif // CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO
131141

@@ -217,9 +227,11 @@
217227
#endif // CONFIG_CHIP_ENABLE_DNS_CLIENT
218228
#endif // CONFIG_CHIP_ENABLE_DNSSD_SRP
219229

220-
#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT
230+
#if defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED)
221231
#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED
222-
#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT
232+
#else
233+
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
234+
#endif // defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED)
223235

224236
#ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
225237
#ifdef CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL
@@ -246,7 +258,7 @@
246258
#endif // CONFIG_CHIP_EXTENDED_DISCOVERY
247259

248260
#ifndef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH
249-
#if CONFIG_CHIP_FACTORY_DATA
261+
#ifdef CONFIG_CHIP_FACTORY_DATA
250262
// UID will be copied from the externally programmed factory data, so we don't know the actual length and we need to assume some max
251263
// boundary.
252264
#define CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH CONFIG_CHIP_FACTORY_DATA_ROTATING_DEVICE_UID_MAX_LEN

src/platform/nrfconnect/CHIPPlatformConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
#define CHIP_CONFIG_MAX_FABRICS 5
7171
#endif
7272

73-
#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
73+
#ifdef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
7474
// Disable some of the too detailed log modules to save flash
7575
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
7676
#define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0

src/platform/nrfconnect/ExternalFlashManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ExternalFlashManager
3535

3636
virtual void DoAction(Action aAction)
3737
{
38-
#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR
38+
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NORDIC_QSPI_NOR)
3939
// utilize the QSPI driver sleep power mode
4040
const auto * qspi_dev = DEVICE_DT_GET(DT_INST(0, nordic_qspi_nor));
4141
if (device_is_ready(qspi_dev))

src/platform/nrfconnect/FactoryDataProvider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "CHIPDevicePlatformConfig.h"
2020
#include <crypto/CHIPCryptoPAL.h>
2121

22-
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
22+
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
2323
#include <credentials/CertificationDeclaration.h>
2424
#include <platform/Zephyr/ZephyrConfig.h>
2525
#endif
@@ -101,7 +101,7 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::Init()
101101
template <class FlashFactoryData>
102102
CHIP_ERROR FactoryDataProvider<FlashFactoryData>::GetCertificationDeclaration(MutableByteSpan & outBuffer)
103103
{
104-
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
104+
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
105105
size_t cdLen = 0;
106106

107107
if (Internal::ZephyrConfig::ReadConfigValueBin(Internal::ZephyrConfig::kConfigKey_CertificationDeclaration,

src/platform/nrfconnect/OTAImageProcessorImpl.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <platform/CHIPDeviceLayer.h>
2626
#include <system/SystemError.h>
2727

28-
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
28+
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
2929
#include <credentials/CertificationDeclaration.h>
3030
#include <platform/Zephyr/ZephyrConfig.h>
3131
#include <zephyr/settings/settings.h>
@@ -40,7 +40,7 @@
4040

4141
namespace chip {
4242
namespace {
43-
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
43+
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
4444
// Cd globals are needed to be accessed from dfu image writer lambdas
4545
uint8_t sCdBuf[chip::Credentials::kMaxCMSSignedCDMessage] = { 0 };
4646
size_t sCdSavedBytes = 0;
@@ -89,7 +89,7 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl()
8989
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer)));
9090
};
9191

92-
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
92+
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
9393
dfu_image_writer cdWriter;
9494
cdWriter.image_id = CONFIG_CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID;
9595
cdWriter.open = [](int id, size_t size) { return size <= sizeof(sCdBuf) ? 0 : -EFBIG; };

src/platform/nrfconnect/wifi/WiFiManager.h

-5
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ class WiFiManager
178178
static_assert(kConnectionRecoveryMinIntervalMs < kConnectionRecoveryMaxIntervalMs);
179179
static_assert(kConnectionRecoveryJitterMs <= kConnectionRecoveryMaxIntervalMs);
180180

181-
#if CHIP_DEVICE_CONFIG_ENABLE_SED
182-
static constexpr uint8_t kDefaultDTIMInterval = 3;
183-
static constexpr uint8_t kBeaconIntervalMs = 100;
184-
#endif
185-
186181
CHIP_ERROR Init();
187182
CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback,
188183
bool internalScan = false);

src/platform/telink/CHIPDevicePlatformConfig.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,19 @@
8787
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
8888
#endif
8989

90+
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
91+
92+
#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI
93+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
94+
#endif
95+
96+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
97+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
98+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
99+
#else
90100
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
91101
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
92-
93-
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
102+
#endif
94103

95104
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT
96105

@@ -187,7 +196,7 @@
187196
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY
188197

189198
#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
190-
#if CONFIG_PM
199+
#ifdef CONFIG_PM
191200
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4864
192201
#else
193202
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192
@@ -237,3 +246,7 @@
237246
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL)
238247
#endif // CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL
239248
#endif // CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL
249+
250+
#ifndef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
251+
#define CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE 0
252+
#endif // CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE

src/platform/telink/CHIPPlatformConfig.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1
6363
#endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS
6464

65-
#if CONFIG_PM
65+
#ifdef CONFIG_PM
6666

6767
#ifndef CHIP_CONFIG_ENABLE_SERVER_IM_EVENT
6868
#define CHIP_CONFIG_ENABLE_SERVER_IM_EVENT 0
@@ -106,6 +106,10 @@
106106
#define CHIP_CONFIG_MAX_FABRICS 5
107107
#endif
108108

109+
#ifndef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
110+
#define CONFIG_CHIP_LOG_SIZE_OPTIMIZATION 0
111+
#endif
112+
109113
#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
110114
// Disable some of the too detailed log modules to save flash
111115
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0

src/platform/telink/SystemPlatformConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct ChipDeviceEvent;
4848
#define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1
4949

5050
// Reduce packet buffer pool size (default 15) to reduce ram consumption
51-
#if CONFIG_PM
51+
#ifdef CONFIG_PM
5252
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0
5353
#else
5454
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8

src/system/SystemConfig.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ struct LwIPEvent;
733733
* Defaults to enabled on Zephyr platforms that do not enable Zephyr POSIX layer.
734734
*/
735735
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
736-
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && CONFIG_NET_SOCKETS_POSIX_NAMES
736+
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && defined(CONFIG_NET_SOCKETS_POSIX_NAMES)
737737
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 1
738738
#else
739739
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 0
@@ -765,7 +765,7 @@ struct LwIPEvent;
765765
* Defaults to enabled on Zephyr platforms that enable CONFIG_EVENTFD.
766766
*/
767767
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
768-
#if defined(__ZEPHYR__) && CONFIG_EVENTFD
768+
#if defined(__ZEPHYR__) && defined(CONFIG_EVENTFD)
769769
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 1
770770
#else
771771
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0

0 commit comments

Comments
 (0)