@@ -171,12 +171,15 @@ extern "C" {
171
171
* @param id Unique ID of the descriptor
172
172
* @param value A string value for the descriptor
173
173
*/
174
- #define BINDESC_STR_DEFINE (name , id , value ) \
175
- __BINDESC_ENTRY_DEFINE(name) = { \
176
- .tag = BINDESC_TAG(STR, id), \
177
- .len = (uint16_t)sizeof(value), \
178
- .data = value, \
179
- }
174
+ #define BINDESC_STR_DEFINE (name , id , value ) \
175
+ __BINDESC_ENTRY_DEFINE(name) = { \
176
+ .tag = BINDESC_TAG(STR, id), \
177
+ .len = (uint16_t)sizeof(value), \
178
+ .data = value, \
179
+ }; \
180
+ BUILD_ASSERT(sizeof(value) <= CONFIG_BINDESC_DEFINE_MAX_DATA_SIZE, \
181
+ "Bindesc " STRINGIFY(name) " exceeded maximum size, consider reducing the" \
182
+ " size or changing CONFIG_BINDESC_DEFINE_MAX_DATA_SIZE. ")
180
183
181
184
/**
182
185
* @brief Define a binary descriptor of type uint.
@@ -217,12 +220,16 @@ extern "C" {
217
220
* @param id Unique ID of the descriptor
218
221
* @param value A uint8_t array as data for the descriptor
219
222
*/
220
- #define BINDESC_BYTES_DEFINE (name , id , value ) \
221
- __BINDESC_ENTRY_DEFINE(name) = { \
222
- .tag = BINDESC_TAG(BYTES, id), \
223
- .len = (uint16_t)sizeof((uint8_t [])__DEBRACKET value), \
224
- .data = __DEBRACKET value, \
225
- }
223
+ #define BINDESC_BYTES_DEFINE (name , id , value ) \
224
+ __BINDESC_ENTRY_DEFINE(name) = { \
225
+ .tag = BINDESC_TAG(BYTES, id), \
226
+ .len = (uint16_t)sizeof((uint8_t [])__DEBRACKET value), \
227
+ .data = __DEBRACKET value, \
228
+ }; \
229
+ BUILD_ASSERT(sizeof((uint8_t [])__DEBRACKET value) <= \
230
+ CONFIG_BINDESC_DEFINE_MAX_DATA_SIZE, \
231
+ "Bindesc " STRINGIFY(name) " exceeded maximum size, consider reducing the" \
232
+ " size or changing CONFIG_BINDESC_DEFINE_MAX_DATA_SIZE. ")
226
233
227
234
/**
228
235
* @brief Get the value of a string binary descriptor
0 commit comments