@@ -1490,7 +1490,8 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1490
1490
#endif
1491
1491
uint8_t const * p_desc = _audiod_fct [i ].p_desc ;
1492
1492
uint8_t const * p_desc_end = p_desc + _audiod_fct [i ].desc_length - TUD_AUDIO_DESC_IAD_LEN ;
1493
- while (p_desc < p_desc_end )
1493
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
1494
+ while (p_desc_end - p_desc > 0 )
1494
1495
{
1495
1496
if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT )
1496
1497
{
@@ -1740,7 +1741,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1740
1741
uint8_t const * p_desc_end = audio -> p_desc + audio -> desc_length - TUD_AUDIO_DESC_IAD_LEN ;
1741
1742
1742
1743
// p_desc starts at required interface with alternate setting zero
1743
- while (p_desc < p_desc_end )
1744
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
1745
+ while (p_desc_end - p_desc > 0 )
1744
1746
{
1745
1747
// Find correct interface
1746
1748
if (tu_desc_type (p_desc ) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )p_desc )-> bInterfaceNumber == itf && ((tusb_desc_interface_t const * )p_desc )-> bAlternateSetting == alt )
@@ -1750,7 +1752,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1750
1752
#endif
1751
1753
// From this point forward follow the EP descriptors associated to the current alternate setting interface - Open EPs if necessary
1752
1754
uint8_t foundEPs = 0 , nEps = ((tusb_desc_interface_t const * )p_desc )-> bNumEndpoints ;
1753
- while (foundEPs < nEps && p_desc < p_desc_end )
1755
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
1756
+ while (foundEPs < nEps && (p_desc_end - p_desc > 0 ))
1754
1757
{
1755
1758
if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT )
1756
1759
{
@@ -2394,7 +2397,8 @@ static bool audiod_get_AS_interface_index(uint8_t itf, audiod_function_t * audio
2394
2397
p_desc += ((audio_desc_cs_ac_interface_t const * )p_desc )-> wTotalLength ;
2395
2398
2396
2399
uint8_t tmp = 0 ;
2397
- while (p_desc < p_desc_end )
2400
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
2401
+ while (p_desc_end - p_desc > 0 )
2398
2402
{
2399
2403
// We assume the number of alternate settings is increasing thus we return the index of alternate setting zero!
2400
2404
if (tu_desc_type (p_desc ) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )p_desc )-> bAlternateSetting == 0 )
@@ -2447,7 +2451,8 @@ static bool audiod_verify_entity_exists(uint8_t itf, uint8_t entityID, uint8_t *
2447
2451
uint8_t const * p_desc_end = ((audio_desc_cs_ac_interface_t const * )p_desc )-> wTotalLength + p_desc ;
2448
2452
p_desc = tu_desc_next (p_desc ); // Get past CS AC descriptor
2449
2453
2450
- while (p_desc < p_desc_end )
2454
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
2455
+ while (p_desc_end - p_desc > 0 )
2451
2456
{
2452
2457
if (p_desc [3 ] == entityID ) // Entity IDs are always at offset 3
2453
2458
{
@@ -2471,8 +2476,8 @@ static bool audiod_verify_itf_exists(uint8_t itf, uint8_t *func_id)
2471
2476
// Get pointer at beginning and end
2472
2477
uint8_t const * p_desc = _audiod_fct [i ].p_desc ;
2473
2478
uint8_t const * p_desc_end = _audiod_fct [i ].p_desc + _audiod_fct [i ].desc_length - TUD_AUDIO_DESC_IAD_LEN ;
2474
-
2475
- while (p_desc < p_desc_end )
2479
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
2480
+ while (p_desc_end - p_desc > 0 )
2476
2481
{
2477
2482
if (tu_desc_type (p_desc ) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )_audiod_fct [i ].p_desc )-> bInterfaceNumber == itf )
2478
2483
{
@@ -2500,7 +2505,8 @@ static bool audiod_verify_ep_exists(uint8_t ep, uint8_t *func_id)
2500
2505
uint8_t const * p_desc = tu_desc_next (_audiod_fct [i ].p_desc );
2501
2506
p_desc += ((audio_desc_cs_ac_interface_t const * )p_desc )-> wTotalLength ;
2502
2507
2503
- while (p_desc < p_desc_end )
2508
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
2509
+ while (p_desc_end - p_desc > 0 )
2504
2510
{
2505
2511
if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT && ((tusb_desc_endpoint_t const * )p_desc )-> bEndpointAddress == ep )
2506
2512
{
@@ -2531,8 +2537,8 @@ static void audiod_parse_for_AS_params(audiod_function_t* audio, uint8_t const *
2531
2537
#endif
2532
2538
2533
2539
p_desc = tu_desc_next (p_desc ); // Exclude standard AS interface descriptor of current alternate interface descriptor
2534
-
2535
- while (p_desc < p_desc_end )
2540
+ // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
2541
+ while (p_desc_end - p_desc > 0 )
2536
2542
{
2537
2543
// Abort if follow up descriptor is a new standard interface descriptor - indicates the last AS descriptor was already finished
2538
2544
if (tu_desc_type (p_desc ) == TUSB_DESC_INTERFACE ) break ;
0 commit comments