Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler warning check in the CI workflow #177

Merged
merged 6 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 )
chinglee-iot marked this conversation as resolved.
Show resolved Hide resolved

# 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
Loading