[gn] enable warnings (#12121)

This commit suppresses the undefined warnings in mbedtls. To detect
such warnings in OpenThread, this commit also enables warnings check
for gn BUILD and fixes issues found.
This commit is contained in:
Yakun Xu
2025-11-09 03:34:48 +08:00
committed by GitHub
parent cfe2999c94
commit a50d1a74dc
7 changed files with 65 additions and 9 deletions
+7
View File
@@ -33,6 +33,13 @@ config("openthread_config") {
defines += [ "OPENTHREAD_CONFIG_FILE=${openthread_config_file}" ]
}
cflags = [
"-Werror",
"-Wall",
"-Wextra",
"-Wundef",
]
include_dirs = openthread_project_include_dirs
include_dirs += [
+9
View File
@@ -629,6 +629,15 @@
#define OPENTHREAD_CONFIG_USE_STD_NEW 0
#endif
/**
* @def OPENTHREAD_PLATFORM_NEXUS
*
* Define 1 to enable nexus platform.
*/
#ifndef OPENTHREAD_PLATFORM_NEXUS
#define OPENTHREAD_PLATFORM_NEXUS 0
#endif
/**
* @}
*/
+8 -2
View File
@@ -79,7 +79,10 @@ static_library("libopenthread-spinel-ncp") {
"../../core:libopenthread_core_headers",
"../platform:libopenthread-platform",
]
public_configs = [ ":spinel_config_openthread_message_enable" ]
public_configs = [
":spinel_config_openthread_message_enable",
"../../..:openthread_ftd_config",
]
}
static_library("libopenthread-spinel-rcp") {
@@ -89,5 +92,8 @@ static_library("libopenthread-spinel-rcp") {
"../../core:libopenthread_core_headers",
"../platform:libopenthread-platform",
]
public_configs = [ ":spinel_config_openthread_message_disable" ]
public_configs = [
":spinel_config_openthread_message_disable",
"../../..:openthread_radio_config",
]
}
+27
View File
@@ -172,4 +172,31 @@
#define OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE 0
#endif
/**
* @def OPENTHREAD_SPINEL_CONFIG_SKIP_RESET_IF_READY
*
* Enables skipping reset if it's ready.
*/
#ifndef OPENTHREAD_SPINEL_CONFIG_SKIP_RESET_IF_READY
#if defined(OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE) && OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
// Avoid resetting the device twice in a row in Multipan RCP architecture
#define OPENTHREAD_SPINEL_CONFIG_SKIP_RESET_IF_READY 1
#else
#define OPENTHREAD_SPINEL_CONFIG_SKIP_RESET_IF_READY 0
#endif
#endif
/**
* @def OPENTHREAD_SPINEL_CONFIG_MAX_INTERFACE_ID
*
* Specifies the maximum number of Spinel interface IDs.
*/
#ifndef OPENTHREAD_SPINEL_CONFIG_MAX_INTERFACE_ID
#if defined(OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE) && OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
#define OPENTHREAD_SPINEL_CONFIG_MAX_INTERFACE_ID 4
#else
#define OPENTHREAD_SPINEL_CONFIG_MAX_INTERFACE_ID 1
#endif
#endif
#endif // OPENTHREAD_SPINEL_CONFIG_H_
+1 -2
View File
@@ -137,8 +137,7 @@ void SpinelDriver::ResetCoprocessor(bool aSoftwareReset)
bool hardwareReset;
bool resetDone = false;
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
// Avoid resetting the device twice in a row in Multipan RCP architecture
#if OPENTHREAD_SPINEL_CONFIG_SKIP_RESET_IF_READY
VerifyOrExit(!mIsCoprocessorReady, resetDone = true);
#endif
+2 -5
View File
@@ -33,6 +33,7 @@
#include "lib/spinel/coprocessor_type.h"
#include "lib/spinel/logger.hpp"
#include "lib/spinel/openthread-spinel-config.h"
#include "lib/spinel/spinel.h"
#include "lib/spinel/spinel_interface.hpp"
@@ -49,11 +50,7 @@ namespace Spinel {
/**
* Maximum number of Spinel Interface IDs.
*/
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
static constexpr uint8_t kSpinelHeaderMaxNumIid = 4;
#else
static constexpr uint8_t kSpinelHeaderMaxNumIid = 1;
#endif
static constexpr uint8_t kSpinelHeaderMaxNumIid = OPENTHREAD_SPINEL_CONFIG_MAX_INTERFACE_ID;
class SpinelDriver : public otSpinelDriver, public Logger
{
+11
View File
@@ -41,8 +41,18 @@ config("mbedtls_config") {
]
defines = [ "MBEDTLS_CONFIG_FILE=\"${mbedtls_config_file}\"" ]
}
config("warnings_fix_config") {
cflags = [
"-Wno-conversion",
"-Wno-undef",
]
}
group("warnings_fix") {
public_configs = [
":warnings_fix_config",
]
}
@@ -314,6 +324,7 @@ static_library("mbedtls") {
]
public_deps = mbedtls_deps
public_deps += [ ":warnings_fix" ]
public_configs = [ ":mbedtls_config" ]
}