43
43
*/
44
44
static uint32_t getZeroTimestampMs ( void );
45
45
46
-
47
- HTTPStatus_t HTTPClient_SendHttpData ( const TransportInterface_t * pTransport ,
48
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
49
- const uint8_t * pData ,
50
- size_t dataLen );
51
-
52
-
53
- HTTPStatus_t HTTPClient_SendHttpHeaders ( const TransportInterface_t * pTransport ,
54
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
55
- HTTPRequestHeaders_t * pRequestHeaders ,
56
- size_t reqBodyLen ,
57
- uint32_t sendFlags );
58
-
59
46
/**
60
47
* @brief Adds the Content-Length header field and value to the
61
48
* @p pRequestHeaders.
@@ -162,11 +149,6 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
162
149
size_t totalReceived ,
163
150
size_t responseBufferLen );
164
151
165
-
166
- HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse ( const TransportInterface_t * pTransport ,
167
- HTTPResponse_t * pResponse ,
168
- const HTTPRequestHeaders_t * pRequestHeaders );
169
-
170
152
/**
171
153
* @brief Send the HTTP request over the network.
172
154
*
@@ -668,7 +650,7 @@ static int httpParserOnStatusCallback( llhttp_t * pHttpParser,
668
650
assert ( pResponse != NULL );
669
651
670
652
/* Set the location of what to parse next. */
671
- pParsingContext -> pBufferCur = pLoc + length ;
653
+ pParsingContext -> pBufferCur = & pLoc [ length ]; ;
672
654
673
655
/* Initialize the first header field and value to be passed to the user
674
656
* callback. */
@@ -748,7 +730,7 @@ static int httpParserOnHeaderFieldCallback( llhttp_t * pHttpParser,
748
730
}
749
731
750
732
/* Set the location of what to parse next. */
751
- pParsingContext -> pBufferCur = pLoc + length ;
733
+ pParsingContext -> pBufferCur = & pLoc [ length ]; ;
752
734
753
735
/* The httpParserOnHeaderFieldCallback() always follows the
754
736
* httpParserOnHeaderValueCallback() if there is another header field. When
@@ -794,7 +776,7 @@ static int httpParserOnHeaderValueCallback( llhttp_t * pHttpParser,
794
776
pParsingContext = ( HTTPParsingContext_t * ) ( pHttpParser -> data );
795
777
796
778
/* Set the location of what to parse next. */
797
- pParsingContext -> pBufferCur = pLoc + length ;
779
+ pParsingContext -> pBufferCur = & pLoc [ length ]; ;
798
780
799
781
/* If httpParserOnHeaderValueCallback() is invoked in succession, then the
800
782
* last time llhttp_execute() was called only part of the header field
@@ -916,7 +898,7 @@ static int httpParserOnHeadersCompleteCallback( llhttp_t * pHttpParser )
916
898
* parsing here. */
917
899
if ( ( pResponse -> respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG ) != 0U )
918
900
{
919
- shouldContinueParse = LLHTTP_PAUSE_PARSING ;
901
+ shouldContinueParse = ( int ) LLHTTP_PAUSE_PARSING ;
920
902
}
921
903
922
904
return shouldContinueParse ;
@@ -963,7 +945,7 @@ static int httpParserOnBodyCallback( llhttp_t * pHttpParser,
963
945
/* MISRA Ref 11.8.1 [Removal of const from pointer] */
964
946
/* More details at: https://github.com/FreeRTOS/coreHTTP/blob/main/MISRA.md#rule-118 */
965
947
/* coverity[misra_c_2012_rule_11_8_violation] */
966
- pNextWriteLoc = ( char * ) ( pResponse -> pBody + pResponse -> bodyLen );
948
+ pNextWriteLoc = ( char * ) ( & pResponse -> pBody [ pResponse -> bodyLen ] );
967
949
968
950
/* If the response is of type Transfer-Encoding: chunked, then actual body
969
951
* will follow the the chunked header. This body data is in a later location
@@ -985,7 +967,7 @@ static int httpParserOnBodyCallback( llhttp_t * pHttpParser,
985
967
pResponse -> bodyLen += length ;
986
968
987
969
/* Set the next location of parsing. */
988
- pParsingContext -> pBufferCur = pLoc + length ;
970
+ pParsingContext -> pBufferCur = & pLoc [ length ]; ;
989
971
990
972
LogDebug ( ( "Response parsing: Found the response body: "
991
973
"BodyLength=%lu" ,
@@ -1243,7 +1225,7 @@ static HTTPStatus_t parseHttpResponse( HTTPParsingContext_t * pParsingContext,
1243
1225
else
1244
1226
{
1245
1227
/* The next location to parse is after what has already been parsed. */
1246
- pParsingContext -> pBufferCur = parsingStartLoc + parseLen ;
1228
+ pParsingContext -> pBufferCur = & parsingStartLoc [ parseLen ] ;
1247
1229
}
1248
1230
1249
1231
returnStatus = processLlhttpError ( & ( pParsingContext -> llhttpParser ) );
@@ -1378,18 +1360,18 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
1378
1360
assert ( fieldLen != 0U );
1379
1361
assert ( valueLen != 0U );
1380
1362
1381
- pBufferCur = ( char * ) ( pRequestHeaders -> pBuffer + pRequestHeaders -> headersLen );
1363
+ pBufferCur = ( char * ) ( & pRequestHeaders -> pBuffer [ pRequestHeaders -> headersLen ] );
1382
1364
backtrackHeaderLen = pRequestHeaders -> headersLen ;
1383
1365
1384
1366
/* Backtrack before trailing "\r\n" (HTTP header end) if it's already written.
1385
1367
* Note that this method also writes trailing "\r\n" before returning.
1386
1368
* The first condition prevents reading before start of the header. */
1387
1369
if ( ( HTTP_HEADER_END_INDICATOR_LEN <= pRequestHeaders -> headersLen ) &&
1388
- ( strncmp ( ( char * ) pBufferCur - HTTP_HEADER_END_INDICATOR_LEN ,
1370
+ ( strncmp ( ( char * ) & pBufferCur [ 0U - HTTP_HEADER_END_INDICATOR_LEN ] ,
1389
1371
HTTP_HEADER_END_INDICATOR , HTTP_HEADER_END_INDICATOR_LEN ) == 0 ) )
1390
1372
{
1391
1373
backtrackHeaderLen -= HTTP_HEADER_LINE_SEPARATOR_LEN ;
1392
- pBufferCur -= HTTP_HEADER_LINE_SEPARATOR_LEN ;
1374
+ pBufferCur = & pBufferCur [ 0U - HTTP_HEADER_LINE_SEPARATOR_LEN ] ;
1393
1375
}
1394
1376
1395
1377
/* Check if there is enough space in buffer for additional header. */
@@ -1411,14 +1393,14 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
1411
1393
1412
1394
if ( returnStatus == HTTPSuccess )
1413
1395
{
1414
- pBufferCur += fieldLen ;
1396
+ pBufferCur = & pBufferCur [ fieldLen ] ;
1415
1397
1416
1398
/* Copy the field separator, ": ", into the buffer. */
1417
1399
( void ) memcpy ( pBufferCur ,
1418
1400
httpFieldSeparator ,
1419
1401
HTTP_HEADER_FIELD_SEPARATOR_LEN );
1420
1402
1421
- pBufferCur += HTTP_HEADER_FIELD_SEPARATOR_LEN ;
1403
+ pBufferCur = & pBufferCur [ HTTP_HEADER_FIELD_SEPARATOR_LEN ] ;
1422
1404
1423
1405
/* Copy the header value into the buffer. */
1424
1406
if ( httpHeaderStrncpy ( pBufferCur , pValue , valueLen , HTTP_HEADER_STRNCPY_IS_VALUE ) == NULL )
@@ -1429,7 +1411,7 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
1429
1411
1430
1412
if ( returnStatus == HTTPSuccess )
1431
1413
{
1432
- pBufferCur += valueLen ;
1414
+ pBufferCur = & pBufferCur [ valueLen ] ;
1433
1415
1434
1416
/* Copy the header end indicator, "\r\n\r\n" into the buffer. */
1435
1417
( void ) memcpy ( pBufferCur ,
@@ -1485,7 +1467,7 @@ static HTTPStatus_t addRangeHeader( HTTPRequestHeaders_t * pRequestHeaders,
1485
1467
1486
1468
/* Write the range start value in the buffer. */
1487
1469
rangeValueLength += convertInt32ToAscii ( rangeStartOrlastNbytes ,
1488
- rangeValueBuffer + rangeValueLength ,
1470
+ & rangeValueBuffer [ rangeValueLength ] ,
1489
1471
sizeof ( rangeValueBuffer ) - rangeValueLength );
1490
1472
1491
1473
/* Add remaining value data depending on the range specification type. */
@@ -1494,19 +1476,19 @@ static HTTPStatus_t addRangeHeader( HTTPRequestHeaders_t * pRequestHeaders,
1494
1476
if ( rangeEnd != HTTP_RANGE_REQUEST_END_OF_FILE )
1495
1477
{
1496
1478
/* Write the "-" character to the buffer.*/
1497
- * ( rangeValueBuffer + rangeValueLength ) = DASH_CHARACTER ;
1479
+ rangeValueBuffer [ rangeValueLength ] = DASH_CHARACTER ;
1498
1480
rangeValueLength += DASH_CHARACTER_LEN ;
1499
1481
1500
1482
/* Write the rangeEnd value of the request range to the buffer. */
1501
1483
rangeValueLength += convertInt32ToAscii ( rangeEnd ,
1502
- rangeValueBuffer + rangeValueLength ,
1484
+ & rangeValueBuffer [ rangeValueLength ] ,
1503
1485
sizeof ( rangeValueBuffer ) - rangeValueLength );
1504
1486
}
1505
1487
/* Case when request is for bytes in the range [rangeStart, EoF). */
1506
1488
else if ( rangeStartOrlastNbytes >= 0 )
1507
1489
{
1508
1490
/* Write the "-" character to the buffer.*/
1509
- * ( rangeValueBuffer + rangeValueLength ) = DASH_CHARACTER ;
1491
+ rangeValueBuffer [ rangeValueLength ] = DASH_CHARACTER ;
1510
1492
rangeValueLength += DASH_CHARACTER_LEN ;
1511
1493
}
1512
1494
else
@@ -1565,32 +1547,32 @@ static HTTPStatus_t writeRequestLine( HTTPRequestHeaders_t * pRequestHeaders,
1565
1547
{
1566
1548
/* Write "<METHOD> <PATH> HTTP/1.1\r\n" to start the HTTP header. */
1567
1549
( void ) memcpy ( pBufferCur , pMethod , methodLen );
1568
- pBufferCur += methodLen ;
1550
+ pBufferCur = & pBufferCur [ methodLen ] ;
1569
1551
1570
1552
* pBufferCur = SPACE_CHARACTER ;
1571
- pBufferCur += SPACE_CHARACTER_LEN ;
1553
+ pBufferCur = & pBufferCur [ SPACE_CHARACTER_LEN ] ;
1572
1554
1573
1555
/* Use "/" as default value if <PATH> is NULL. */
1574
1556
if ( ( pPath == NULL ) || ( pathLen == 0U ) )
1575
1557
{
1576
1558
( void ) memcpy ( pBufferCur ,
1577
1559
pHttpEmptyPath ,
1578
1560
HTTP_EMPTY_PATH_LEN );
1579
- pBufferCur += HTTP_EMPTY_PATH_LEN ;
1561
+ pBufferCur = & pBufferCur [ HTTP_EMPTY_PATH_LEN ] ;
1580
1562
}
1581
1563
else
1582
1564
{
1583
1565
( void ) memcpy ( pBufferCur , pPath , pathLen );
1584
- pBufferCur += pathLen ;
1566
+ pBufferCur = & pBufferCur [ pathLen ] ;
1585
1567
}
1586
1568
1587
1569
* pBufferCur = SPACE_CHARACTER ;
1588
- pBufferCur += SPACE_CHARACTER_LEN ;
1570
+ pBufferCur = & pBufferCur [ SPACE_CHARACTER_LEN ] ;
1589
1571
1590
1572
( void ) memcpy ( pBufferCur ,
1591
1573
pHttpProtocolVersion ,
1592
1574
HTTP_PROTOCOL_VERSION_LEN );
1593
- pBufferCur += HTTP_PROTOCOL_VERSION_LEN ;
1575
+ pBufferCur = & pBufferCur [ HTTP_PROTOCOL_VERSION_LEN ] ;
1594
1576
( void ) memcpy ( pBufferCur ,
1595
1577
pHeaderLineSeparator ,
1596
1578
HTTP_HEADER_LINE_SEPARATOR_LEN );
@@ -1880,7 +1862,7 @@ HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport,
1880
1862
lastSendTimeMs = getTimestampMs ();
1881
1863
1882
1864
bytesRemaining -= ( size_t ) bytesSent ;
1883
- pIndex += bytesSent ;
1865
+ pIndex = & pIndex [ bytesSent ] ;
1884
1866
LogDebug ( ( "Sent data over the transport: "
1885
1867
"BytesSent=%ld, BytesRemaining=%lu, TotalBytesSent=%lu" ,
1886
1868
( long int ) bytesSent ,
@@ -2081,7 +2063,7 @@ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t
2081
2063
{
2082
2064
/* Receive the HTTP response data into the pResponse->pBuffer. */
2083
2065
currentReceived = pTransport -> recv ( pTransport -> pNetworkContext ,
2084
- pResponse -> pBuffer + totalReceived ,
2066
+ & pResponse -> pBuffer [ totalReceived ] ,
2085
2067
pResponse -> bufferLen - totalReceived );
2086
2068
2087
2069
/* Transport receive errors are negative. */
@@ -2157,6 +2139,10 @@ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t
2157
2139
/* There may be dangling data if we parse with do not parse body flag.
2158
2140
* We expose this data through body to let the applications access it. */
2159
2141
pResponse -> pBody = ( const uint8_t * ) parsingContext .pBufferCur ;
2142
+
2143
+ /* MISRA Ref 11.4.1 [Casting pointer to int] */
2144
+ /* More details at: https://github.com/FreeRTOS/coreHTTP/blob/main/MISRA.md#rule-114 */
2145
+ /* coverity[misra_c_2012_rule_11_4_violation] */
2160
2146
pResponse -> bodyLen = totalReceived - ( size_t ) ( ( ( uintptr_t ) pResponse -> pBody ) - ( ( uintptr_t ) pResponse -> pBuffer ) );
2161
2147
}
2162
2148
0 commit comments