Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Telink] Enable -Wundef by default on Zephyr platform #29613

Merged
merged 24 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Telink] clean code
  • Loading branch information
s07641069 committed Oct 7, 2023
commit 939e95b69c2dd406cc585ac98e83eb0e46def238
36 changes: 21 additions & 15 deletions src/platform/nrfconnect/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
#endif

#ifdef CONFIG_NET_L2_OPENTHREAD
#ifndef CONFIG_NET_L2_OPENTHREAD
#define CONFIG_NET_L2_OPENTHREAD 0
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
#else
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0

#ifndef CONFIG_WIFI_NRF700X
#define CONFIG_WIFI_NRF700X 0
#endif

#ifdef CONFIG_WIFI_NRF700X
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI CONFIG_WIFI_NRF700X
#else
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
Expand All @@ -107,12 +107,12 @@
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
#endif

#ifdef CONFIG_BT
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT
#else
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
#ifndef CONFIG_BT
#define CONFIG_BT 0
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT

// ========== Platform-specific Configuration =========

// These are configuration options that are unique to Zephyr platforms.
Expand Down Expand Up @@ -231,10 +231,12 @@
#endif // CONFIG_CHIP_ENABLE_DNS_CLIENT
#endif // CONFIG_CHIP_ENABLE_DNSSD_SRP

#if defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED)
#ifndef CONFIG_CHIP_THREAD_SSED
#define CONFIG_CHIP_THREAD_SSED 0
#endif

#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT
#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED
#else
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT

#ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
Expand All @@ -261,8 +263,12 @@
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
#endif // CONFIG_CHIP_EXTENDED_DISCOVERY

#ifndef CONFIG_CHIP_FACTORY_DATA
#define CONFIG_CHIP_FACTORY_DATA 0
#endif

#ifndef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH
#if defined(CONFIG_CHIP_FACTORY_DATA) && CONFIG_CHIP_FACTORY_DATA
#ifdef CONFIG_CHIP_FACTORY_DATA
// 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
// boundary.
#define CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH CONFIG_CHIP_FACTORY_DATA_ROTATING_DEVICE_UID_MAX_LEN
Expand Down
18 changes: 17 additions & 1 deletion src/platform/nrfconnect/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
#define CHIP_CONFIG_MAX_FABRICS 5
#endif

#if defined(CONFIG_CHIP_LOG_SIZE_OPTIMIZATION) && CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#ifndef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#define CONFIG_CHIP_LOG_SIZE_OPTIMIZATION 0
#endif

#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
// Disable some of the too detailed log modules to save flash
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0
Expand Down Expand Up @@ -135,3 +139,15 @@
#define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC CONFIG_CHIP_ICD_CLIENTS_PER_FABRIC
#endif // CONFIG_CHIP_ICD_CLIENTS_PER_FABRIC
#endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC

#ifndef CONFIG_PM_DEVICE
#define CONFIG_PM_DEVICE 0
#endif // CONFIG_PM_DEVICE

#ifndef CONFIG_NORDIC_QSPI_NOR
#define CONFIG_NORDIC_QSPI_NOR 0
#endif // CONFIG_NORDIC_QSPI_NOR

#ifndef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#define CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE 0
#endif // CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
4 changes: 3 additions & 1 deletion src/platform/nrfconnect/ExternalFlashManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <zephyr/device.h>
#include <zephyr/pm/device.h>

#include "CHIPPlatformConfig.h"

namespace chip {
namespace DeviceLayer {

Expand All @@ -35,7 +37,7 @@ class ExternalFlashManager

virtual void DoAction(Action aAction)
{
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NORDIC_QSPI_NOR)
#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR
// utilize the QSPI driver sleep power mode
const auto * qspi_dev = DEVICE_DT_GET(DT_INST(0, nordic_qspi_nor));
if (device_is_ready(qspi_dev))
Expand Down
8 changes: 5 additions & 3 deletions src/platform/nrfconnect/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <platform/CHIPDeviceLayer.h>
#include <system/SystemError.h>

#if defined(CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE) && CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#include "CHIPPlatformConfig.h"

#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#include <credentials/CertificationDeclaration.h>
#include <platform/Zephyr/ZephyrConfig.h>
#include <zephyr/settings/settings.h>
Expand All @@ -40,7 +42,7 @@

namespace chip {
namespace {
#if defined(CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE) && CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
// Cd globals are needed to be accessed from dfu image writer lambdas
uint8_t sCdBuf[chip::Credentials::kMaxCMSSignedCDMessage] = { 0 };
size_t sCdSavedBytes = 0;
Expand Down Expand Up @@ -89,7 +91,7 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl()
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer)));
};

#if defined(CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE) && CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
dfu_image_writer cdWriter;
cdWriter.image_id = CONFIG_CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID;
cdWriter.open = [](int id, size_t size) { return size <= sizeof(sCdBuf) ? 0 : -EFBIG; };
Expand Down
10 changes: 9 additions & 1 deletion src/platform/telink/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@
#define CHIP_CONFIG_MAX_FABRICS 5
#endif

#if defined(CONFIG_CHIP_LOG_SIZE_OPTIMIZATION) && CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#ifndef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#define CONFIG_CHIP_LOG_SIZE_OPTIMIZATION 0
#endif

#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
// Disable some of the too detailed log modules to save flash
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0
Expand Down Expand Up @@ -155,3 +159,7 @@
#define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC CONFIG_CHIP_ICD_CLIENTS_PER_FABRIC
#endif // CONFIG_CHIP_ICD_CLIENTS_PER_FABRIC
#endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC

#ifndef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#define CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE 0
#endif // CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
4 changes: 2 additions & 2 deletions src/platform/telink/FactoryDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "CHIPDevicePlatformConfig.h"
#include <crypto/CHIPCryptoPAL.h>

#if defined(CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE) && CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#include <credentials/CertificationDeclaration.h>
#include <platform/Zephyr/ZephyrConfig.h>
#endif
Expand Down Expand Up @@ -101,7 +101,7 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::Init()
template <class FlashFactoryData>
CHIP_ERROR FactoryDataProvider<FlashFactoryData>::GetCertificationDeclaration(MutableByteSpan & outBuffer)
{
#if defined(CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE) && CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
ReturnErrorCodeIf(outBuffer.size() < mFactoryData.certificate_declaration.len, CHIP_ERROR_BUFFER_TOO_SMALL);
ReturnErrorCodeIf(!mFactoryData.certificate_declaration.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND);

Expand Down
12 changes: 10 additions & 2 deletions src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ struct LwIPEvent;
#endif
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS

// #include "CHIPDevicePlatformConfig.h"
// #include "CHIPPlatformConfig.h"
/**
* @def CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
*
Expand All @@ -732,8 +734,11 @@ struct LwIPEvent;
*
* Defaults to enabled on Zephyr platforms that do not enable Zephyr POSIX layer.
*/
#ifndef CONFIG_NET_SOCKETS_POSIX_NAMES
#define CONFIG_NET_SOCKETS_POSIX_NAMES 0
#endif
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && defined(CONFIG_NET_SOCKETS_POSIX_NAMES)
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && CONFIG_NET_SOCKETS_POSIX_NAMES
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 1
#else
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 0
Expand Down Expand Up @@ -764,8 +769,11 @@ struct LwIPEvent;
*
* Defaults to enabled on Zephyr platforms that enable CONFIG_EVENTFD.
*/
#ifndef CONFIG_EVENTFD
#define CONFIG_EVENTFD 0
#endif
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
#if defined(__ZEPHYR__) && defined(CONFIG_EVENTFD)
#if defined(__ZEPHYR__) && CONFIG_EVENTFD
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 1
#else
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0
Expand Down