Skip to content

Commit a3dfc82

Browse files
committed
fix(build): add __attribute__((nonstring)) to nonsting variables
1 parent b65502f commit a3dfc82

File tree

13 files changed

+34
-10
lines changed

13 files changed

+34
-10
lines changed

components/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* BTC.
2323
*
2424
******************************************************************************/
25+
#include "esp_attr.h"
2526
#include "string.h"
2627
#include "common/bt_target.h"
2728
#include "stack/a2d_api.h"
@@ -66,7 +67,7 @@
6667
#define BTA_AV_CO_SBC_MAX_BITPOOL 53
6768

6869
/* SCMS-T protect info */
69-
const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = "\x02\x02\x00";
70+
const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = { 2, 2, 0 };
7071

7172
/* SBC SRC codec capabilities */
7273
const tA2D_SBC_CIE bta_av_co_sbc_caps = {

components/esp_common/include/esp_attr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ extern "C" {
161161
// Forces to not inline function
162162
#define NOINLINE_ATTR __attribute__((noinline))
163163

164+
#if !defined(__clang__) && __GNUC__ >= 15
165+
// Marks a character array as not null-terminated to avoid string-related optimizations or warnings
166+
#define NONSTRING_ATTR __attribute__ ((nonstring))
167+
#else
168+
#define NONSTRING_ATTR
169+
#endif
170+
164171
// This allows using enum as flags in C++
165172
// Format: FLAG_ATTR(flag_enum_t)
166173
#ifdef __cplusplus

components/esp_driver_uart/include/driver/uart_wakeup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#pragma once
88

99
#include "esp_err.h"
10+
#include "esp_attr.h"
1011
#include "soc/soc_caps.h"
1112
#include "hal/uart_types.h"
1213

@@ -45,7 +46,7 @@ typedef struct {
4546
'*' represents any symbol.
4647
The end character cannot be '*'.
4748
Example: "he**o" matches hello, heyyo. */
48-
char wake_chars_seq[SOC_UART_WAKEUP_CHARS_SEQ_MAX_LEN];
49+
NONSTRING_ATTR char wake_chars_seq[SOC_UART_WAKEUP_CHARS_SEQ_MAX_LEN];
4950
#endif
5051

5152
} uart_wakeup_cfg_t;

components/esp_phy/esp32/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include "esp_phy_init.h"
10+
#include "esp_attr.h"
1011
#include "sdkconfig.h"
1112

1213
#ifdef __cplusplus
@@ -50,7 +51,7 @@ typedef struct {
5051
* @brief Country corresponds to PHY init data type structure
5152
*/
5253
typedef struct {
53-
char cc[PHY_COUNTRY_CODE_LEN];
54+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5455
uint8_t type;
5556
} phy_country_to_bin_type_t;
5657
#endif

components/esp_phy/esp32c2/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include "esp_phy_init.h"
10+
#include "esp_attr.h"
1011
#include "sdkconfig.h"
1112

1213
#ifdef __cplusplus
@@ -51,7 +52,7 @@ typedef struct {
5152
* @brief Country corresponds to PHY init data type structure
5253
*/
5354
typedef struct {
54-
char cc[PHY_COUNTRY_CODE_LEN];
55+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5556
uint8_t type;
5657
} phy_country_to_bin_type_t;
5758
#endif

components/esp_phy/esp32c3/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include "esp_phy_init.h"
10+
#include "esp_attr.h"
1011
#include "sdkconfig.h"
1112

1213
#ifdef __cplusplus
@@ -51,7 +52,7 @@ typedef struct {
5152
* @brief Country corresponds to PHY init data type structure
5253
*/
5354
typedef struct {
54-
char cc[PHY_COUNTRY_CODE_LEN];
55+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5556
uint8_t type;
5657
} phy_country_to_bin_type_t;
5758
#endif

components/esp_phy/esp32c5/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include <stdint.h>
10+
#include "esp_attr.h"
1011
#include "esp_phy_init.h"
1112
#include "sdkconfig.h"
1213

@@ -52,7 +53,7 @@ typedef struct {
5253
* @brief Country corresponds to PHY init data type structure
5354
*/
5455
typedef struct {
55-
char cc[PHY_COUNTRY_CODE_LEN];
56+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5657
uint8_t type;
5758
} phy_country_to_bin_type_t;
5859
#endif

components/esp_phy/esp32c6/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include "esp_phy_init.h"
10+
#include "esp_attr.h"
1011
#include "sdkconfig.h"
1112

1213
#ifdef __cplusplus
@@ -51,7 +52,7 @@ typedef struct {
5152
* @brief Country corresponds to PHY init data type structure
5253
*/
5354
typedef struct {
54-
char cc[PHY_COUNTRY_CODE_LEN];
55+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5556
uint8_t type;
5657
} phy_country_to_bin_type_t;
5758
#endif

components/esp_phy/esp32c61/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include <stdint.h>
1010
#include "esp_phy_init.h"
11+
#include "esp_attr.h"
1112
#include "sdkconfig.h"
1213

1314
#ifdef __cplusplus
@@ -52,7 +53,7 @@ typedef struct {
5253
* @brief Country corresponds to PHY init data type structure
5354
*/
5455
typedef struct {
55-
char cc[PHY_COUNTRY_CODE_LEN];
56+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5657
uint8_t type;
5758
} phy_country_to_bin_type_t;
5859
#endif

components/esp_phy/esp32s2/include/phy_init_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PHY_INIT_DATA_H
88
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
99
#include "esp_phy_init.h"
10+
#include "esp_attr.h"
1011
#include "sdkconfig.h"
1112

1213
#ifdef __cplusplus
@@ -51,7 +52,7 @@ typedef struct {
5152
* @brief Country corresponds to PHY init data type structure
5253
*/
5354
typedef struct {
54-
char cc[PHY_COUNTRY_CODE_LEN];
55+
NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN];
5556
uint8_t type;
5657
} phy_country_to_bin_type_t;
5758
#endif

0 commit comments

Comments
 (0)