Skip to content

Commit 929b540

Browse files
committed
fix: warning outside array bounds
array subscript 'TL_CcEvt_t[0]' is partly outside array bounds Signed-off-by: Frederic Pillon <[email protected]>
1 parent b0a1849 commit 929b540

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

src/utility/STM32Cube_FW/shci.c

+28-28
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code )
4242
/**
4343
* A command status event + payload has the same size than the expected command complete
4444
*/
45-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1];
45+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
4646
TL_EvtPacket_t * p_rsp;
4747

4848
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -66,7 +66,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_a
6666
* TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters
6767
* Buffer is large enough to hold command complete without payload
6868
*/
69-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
69+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
7070
TL_EvtPacket_t * p_rsp;
7171
uint32_t *p_cmd;
7272
uint8_t cmd_length;
@@ -101,7 +101,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void )
101101
/**
102102
* Buffer is large enough to hold command complete without payload
103103
*/
104-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
104+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
105105
TL_EvtPacket_t * p_rsp;
106106

107107
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -119,7 +119,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_
119119
/**
120120
* Buffer is large enough to hold command complete without payload
121121
*/
122-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
122+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
123123
TL_EvtPacket_t * p_rsp;
124124

125125
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -137,7 +137,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void )
137137
/**
138138
* Buffer is large enough to hold command complete without payload
139139
*/
140-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
140+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
141141
TL_EvtPacket_t * p_rsp;
142142

143143
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -155,7 +155,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *p
155155
/**
156156
* Buffer is large enough to hold command complete without payload
157157
*/
158-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1];
158+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
159159
TL_EvtPacket_t * p_rsp;
160160
uint8_t local_payload_len;
161161

@@ -189,7 +189,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index )
189189
/**
190190
* Buffer is large enough to hold command complete without payload
191191
*/
192-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
192+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
193193
TL_EvtPacket_t * p_rsp;
194194

195195
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -209,7 +209,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void )
209209
/**
210210
* Buffer is large enough to hold command complete without payload
211211
*/
212-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
212+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
213213
TL_EvtPacket_t * p_rsp;
214214

215215
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -227,7 +227,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index )
227227
/**
228228
* Buffer is large enough to hold command complete without payload
229229
*/
230-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
230+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
231231
TL_EvtPacket_t * p_rsp;
232232

233233
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -247,7 +247,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index )
247247
/**
248248
* Buffer is large enough to hold command complete without payload
249249
*/
250-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
250+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
251251
TL_EvtPacket_t * p_rsp;
252252

253253
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -267,7 +267,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void )
267267
/**
268268
* Buffer is large enough to hold command complete without payload
269269
*/
270-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
270+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
271271
TL_EvtPacket_t * p_rsp;
272272

273273
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -285,7 +285,7 @@ SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket )
285285
/**
286286
* Buffer is large enough to hold command complete without payload
287287
*/
288-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
288+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
289289
TL_EvtPacket_t * p_rsp;
290290

291291
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -303,7 +303,7 @@ SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void )
303303
/**
304304
* Buffer is large enough to hold command complete without payload
305305
*/
306-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
306+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
307307
TL_EvtPacket_t * p_rsp;
308308

309309
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -321,7 +321,7 @@ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param )
321321
/**
322322
* Buffer is large enough to hold command complete without payload
323323
*/
324-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
324+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
325325
TL_EvtPacket_t * p_rsp;
326326

327327
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -339,7 +339,7 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param )
339339
/**
340340
* Buffer is large enough to hold command complete without payload
341341
*/
342-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
342+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
343343
TL_EvtPacket_t * p_rsp;
344344

345345
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -357,7 +357,7 @@ SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket
357357
/**
358358
* Buffer is large enough to hold command complete without payload
359359
*/
360-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
360+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
361361
TL_EvtPacket_t * p_rsp;
362362

363363
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -375,7 +375,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activit
375375
/**
376376
* Buffer is large enough to hold command complete without payload
377377
*/
378-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
378+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
379379
TL_EvtPacket_t * p_rsp;
380380

381381
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -395,7 +395,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mod
395395
/**
396396
* Buffer is large enough to hold command complete without payload
397397
*/
398-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
398+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
399399
TL_EvtPacket_t * p_rsp;
400400

401401
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -415,7 +415,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNex
415415
/**
416416
* Buffer is large enough to hold command complete without payload
417417
*/
418-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE+4];
418+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
419419
TL_EvtPacket_t * p_rsp;
420420

421421
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -435,7 +435,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void )
435435
/**
436436
* Buffer is large enough to hold command complete without payload
437437
*/
438-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
438+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
439439
TL_EvtPacket_t * p_rsp;
440440

441441
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -453,7 +453,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip )
453453
/**
454454
* Buffer is large enough to hold command complete without payload
455455
*/
456-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
456+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
457457
TL_EvtPacket_t * p_rsp;
458458

459459
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -473,7 +473,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip )
473473
/**
474474
* Buffer is large enough to hold command complete without payload
475475
*/
476-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
476+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
477477
TL_EvtPacket_t * p_rsp;
478478

479479
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -493,7 +493,7 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla
493493
/**
494494
* Buffer is large enough to hold command complete without payload
495495
*/
496-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
496+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
497497
TL_EvtPacket_t * p_rsp;
498498

499499
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -514,7 +514,7 @@ SHCI_CmdStatus_t SHCI_C2_Reinit( void )
514514
/**
515515
* Buffer is large enough to hold command complete without payload
516516
*/
517-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
517+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
518518
TL_EvtPacket_t * p_rsp;
519519

520520
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -533,7 +533,7 @@ SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_numbe
533533
* TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters
534534
* Buffer is large enough to hold command complete without payload
535535
*/
536-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
536+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
537537
TL_EvtPacket_t * p_rsp;
538538

539539
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -557,7 +557,7 @@ SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONT
557557
* TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter
558558
* Buffer is large enough to hold command complete without payload
559559
*/
560-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
560+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
561561
TL_EvtPacket_t * p_rsp;
562562

563563
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -577,7 +577,7 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket)
577577
/**
578578
* Buffer is large enough to hold command complete without payload
579579
*/
580-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
580+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
581581
TL_EvtPacket_t * p_rsp;
582582

583583
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -595,7 +595,7 @@ SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void )
595595
/**
596596
* Buffer is large enough to hold command complete without payload
597597
*/
598-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
598+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
599599
TL_EvtPacket_t * p_rsp;
600600

601601
p_rsp = (TL_EvtPacket_t *)local_buffer;

src/utility/STM32Cube_FW/tl.h

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ extern "C" {
6161
#define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t))
6262
#define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE)
6363

64+
#define TL_BLEEVT_CC_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CcEvt_t))
65+
#define TL_BLEEVT_CC_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CC_PACKET_SIZE)
66+
6467
/* Exported types ------------------------------------------------------------*/
6568
/**< Packet header */
6669
typedef PACKED_STRUCT

0 commit comments

Comments
 (0)