Skip to content

Commit 1ec4563

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 9b421c2 commit 1ec4563

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

src/utility/STM32Cube_FW/shci.c

+30-30
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_ZIGBEE_Init( void )
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_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket
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;
@@ -393,7 +393,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activit
393393
/**
394394
* Buffer is large enough to hold command complete without payload
395395
*/
396-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
396+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
397397
TL_EvtPacket_t * p_rsp;
398398

399399
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -413,7 +413,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mod
413413
/**
414414
* Buffer is large enough to hold command complete without payload
415415
*/
416-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
416+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
417417
TL_EvtPacket_t * p_rsp;
418418

419419
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -433,7 +433,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNex
433433
/**
434434
* Buffer is large enough to hold command complete without payload
435435
*/
436-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE+4];
436+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
437437
TL_EvtPacket_t * p_rsp;
438438

439439
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -453,7 +453,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void )
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;
@@ -471,7 +471,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip )
471471
/**
472472
* Buffer is large enough to hold command complete without payload
473473
*/
474-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
474+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
475475
TL_EvtPacket_t * p_rsp;
476476

477477
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -491,7 +491,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip )
491491
/**
492492
* Buffer is large enough to hold command complete without payload
493493
*/
494-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
494+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
495495
TL_EvtPacket_t * p_rsp;
496496

497497
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -511,7 +511,7 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla
511511
/**
512512
* Buffer is large enough to hold command complete without payload
513513
*/
514-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
514+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
515515
TL_EvtPacket_t * p_rsp;
516516

517517
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -532,7 +532,7 @@ SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void )
532532
/**
533533
* Buffer is large enough to hold command complete without payload
534534
*/
535-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
535+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
536536
TL_EvtPacket_t * p_rsp;
537537

538538
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -550,7 +550,7 @@ SHCI_CmdStatus_t SHCI_C2_Reinit( void )
550550
/**
551551
* Buffer is large enough to hold command complete without payload
552552
*/
553-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
553+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
554554
TL_EvtPacket_t * p_rsp;
555555

556556
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -569,7 +569,7 @@ SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_numbe
569569
* TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters
570570
* Buffer is large enough to hold command complete without payload
571571
*/
572-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
572+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
573573
TL_EvtPacket_t * p_rsp;
574574

575575
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -593,7 +593,7 @@ SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONT
593593
* TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter
594594
* Buffer is large enough to hold command complete without payload
595595
*/
596-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
596+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
597597
TL_EvtPacket_t * p_rsp;
598598

599599
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -613,7 +613,7 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket)
613613
/**
614614
* Buffer is large enough to hold command complete without payload
615615
*/
616-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
616+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
617617
TL_EvtPacket_t * p_rsp;
618618

619619
p_rsp = (TL_EvtPacket_t *)local_buffer;
@@ -631,7 +631,7 @@ SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void )
631631
/**
632632
* Buffer is large enough to hold command complete without payload
633633
*/
634-
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
634+
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
635635
TL_EvtPacket_t * p_rsp;
636636

637637
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)