Skip to content

Commit

Permalink
Merge branch 'main' into add-more-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglee-iot committed May 7, 2024
2 parents 9d6b3e6 + dd62128 commit 4aed67e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ utest
vect
Vect
VECT
Wconversion
Werror
Weverything
Wextra
Wpedantic
Wunused
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ jobs:
- name: Build
run: |
sudo apt-get install -y lcov
# Build the coverity analysis project as well to check compiler warning.
# Coverity analysis project builds coreHTTP source file only. llhttp source
# files are not built in this target.
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DUNITTEST=1 \
-DCOV_ANALYSIS=1 \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG'
make -C build/ all
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_id }}
- name: Configure git identity
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Install ZIP tools
run: sudo apt-get install zip unzip
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_id }}
path: coreHTTP
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
ctest -E system --output-on-failure
cd ..
- name: Create artifact of ZIP
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: coreHTTP-${{ github.event.inputs.version_number }}.zip
path: zip-check/coreHTTP-${{ github.event.inputs.version_number }}.zip
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
draft: false
prerelease: false
- name: Download ZIP artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: coreHTTP-${{ github.event.inputs.version_number }}.zip
- name: Upload Release Asset
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ repositories.

### Generating Documentation

The Doxygen references were created using Doxygen version 1.9.2. To generate the
The Doxygen references were created using Doxygen version 1.9.6. To generate the
Doxygen pages, please run the following command from the root of this
repository:

Expand Down
15 changes: 15 additions & 0 deletions docs/doxygen/pages.dox
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ defined.
@subpage httpclient_initializerequestheaders_function <br>
@subpage httpclient_addheader_function <br>
@subpage httpclient_addrangeheader_function <br>
@subpage httpclient_sendhttpheaders_function <br>
@subpage httpclient_sendhttpdata_function <br>
@subpage httpclient_send_function <br>
@subpage httpclient_receiveandparsehttpresponse_function <br>
@subpage httpclient_readheader_function <br>
@subpage httpclient_strerror_function <br>

Expand All @@ -286,10 +289,22 @@ defined.
@snippet core_http_client.h declare_httpclient_addrangeheader
@copydoc HTTPClient_AddRangeHeader

@page httpclient_sendhttpheaders_function HTTPClient_SendHttpHeaders
@snippet core_http_client.h declare_httpclient_sendhttpheaders
@copydoc HTTPClient_SendHttpHeaders

@page httpclient_sendhttpdata_function HTTPClient_SendHttpData
@snippet core_http_client.h declare_httpclient_sendhttpdata
@copydoc HTTPClient_SendHttpData

@page httpclient_send_function HTTPClient_Send
@snippet core_http_client.h declare_httpclient_send
@copydoc HTTPClient_Send

@page httpclient_receiveandparsehttpresponse_function HTTPClient_ReceiveAndParseHttpResponse
@snippet core_http_client.h declare_httpclient_receiveandparsehttpresponse
@copydoc HTTPClient_ReceiveAndParseHttpResponse

@page httpclient_readheader_function HTTPClient_ReadHeader
@snippet core_http_client.h declare_httpclient_readheader
@copydoc HTTPClient_ReadHeader
Expand Down
14 changes: 8 additions & 6 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ static int8_t caseInsensitiveStringCmp( const char * str1,
/* Subtract offset to go from lowercase to uppercase ASCII character */
if( ( firstChar >= 'a' ) && ( firstChar <= 'z' ) )
{
firstChar = firstChar - offset;
firstChar = ( char ) ( firstChar - offset );
}

if( ( secondChar >= 'a' ) && ( secondChar <= 'z' ) )
{
secondChar = secondChar - offset;
secondChar = ( char ) ( secondChar - offset );
}

if( ( firstChar ) != ( secondChar ) )
Expand Down Expand Up @@ -1249,6 +1249,7 @@ static uint8_t convertInt32ToAscii( int32_t value,
uint8_t numOfDigits = 0U;
uint8_t index = 0U;
uint8_t isNegative = 0U;
int32_t bufferIndex;
char temp = '\0';

assert( pBuffer != NULL );
Expand All @@ -1263,7 +1264,7 @@ static uint8_t convertInt32ToAscii( int32_t value,
*pBuffer = '-';

/* Convert the value to its absolute representation. */
absoluteValue = value * -1;
absoluteValue = value * ( -1 );
}

/* Write the absolute integer value in reverse ASCII representation. */
Expand All @@ -1279,11 +1280,12 @@ static uint8_t convertInt32ToAscii( int32_t value,
for( index = 0U; index < ( numOfDigits / 2U ); index++ )
{
temp = pBuffer[ isNegative + index ];
pBuffer[ isNegative + index ] = pBuffer[ isNegative + numOfDigits - index - 1U ];
pBuffer[ isNegative + numOfDigits - index - 1U ] = temp;
bufferIndex = ( int32_t ) isNegative + ( int32_t ) numOfDigits - ( int32_t ) index - 1;
pBuffer[ isNegative + index ] = pBuffer[ bufferIndex ];
pBuffer[ bufferIndex ] = temp;
}

return( isNegative + numOfDigits );
return ( uint8_t ) ( isNegative + numOfDigits );
}

/*-----------------------------------------------------------*/
Expand Down
15 changes: 12 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,25 @@ if( COV_ANALYSIS )

# Target for Coverity analysis that builds the library.
add_library( coverity_analysis
${HTTP_SOURCES} )
${CMAKE_CURRENT_LIST_DIR}/../source/core_http_client.c )

# Build HTTP library target without custom config dependency.
target_compile_definitions( coverity_analysis PUBLIC HTTP_DO_NOT_USE_CUSTOM_CONFIG=1 )

# HTTP public include path.
target_include_directories( coverity_analysis PUBLIC ${HTTP_INCLUDE_PUBLIC_DIRS} )

# Build HTTP library target without logging
target_compile_options(coverity_analysis PUBLIC -DNDEBUG )
target_compile_options( coverity_analysis PUBLIC
# Build HTTP library target without logging
-DNDEBUG

# GCC compiler option
-Wall
-Wextra
-Wpedantic
-Wconversion
-Werror
)
endif()
# ===================== Clone needed third-party libraries ======================

Expand Down

0 comments on commit 4aed67e

Please sign in to comment.