aws / aws-iot-core-mqtt-file-streams-embedded-c

MIT License
2 stars 5 forks source link

Remove asserts from static functions #28

Closed kar-rahul-aws closed 4 months ago

kar-rahul-aws commented 4 months ago

Description

This PR removes unnecessary asserts from static functions. The NULL check for the pointer variables are unnecessary , since these are static functions and non-NULL values are always passed from the caller functions. As a result, the code coverage increases.

Test Steps

make -C build/ coverage
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*vendor/unity\*" "\*_deps\*")
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
lcov --rc lcov_branch_coverage=1 --list build/coverage.info

Before patch

                                   |Lines       |Functions  |Branches    
Filename                           |Rate     Num|Rate    Num|Rate     Num
=========================================================================
[/home/ubuntu/Temp/karahulx_coreMQTTFileStreams/aws-iot-core-mqtt-file-streams-embedded-c/source/]
MQTTFileDownloader.c               |97.3%    146| 100%     9|96.0%    100
MQTTFileDownloader_base64.c        |99.0%    103| 100%     4|85.2%     88
MQTTFileDownloader_cbor.c          | 100%     85| 100%     3| 100%     88
=========================================================================
                             Total:|98.5%    334| 100%    16|93.8%    276

After patch

                                   |Lines       |Functions  |Branches    
Filename                           |Rate     Num|Rate    Num|Rate     Num
=========================================================================
[/home/ubuntu/Temp/karahulx_coreMQTTFileStreams/aws-iot-core-mqtt-file-streams-embedded-c/source/]
MQTTFileDownloader.c               |97.3%    146| 100%     9|96.0%    100
MQTTFileDownloader_base64.c        |98.9%     95| 100%     4|93.1%     72
MQTTFileDownloader_cbor.c          | 100%     85| 100%     3| 100%     88
=========================================================================
                             Total:|98.5%    326| 100%    16|96.5%    260

Checklist:

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.