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

Fix gcc warnings in core_http_client.c. Update ci.yml. #101

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

paulbartell
Copy link

@paulbartell paulbartell commented Apr 27, 2021

Fix gcc warnings in http_parser and core_http_client.c.

Update ci.yml to use the latest ubuntu image and -Werror and -fsanitize.

@paulbartell paulbartell changed the title Fix gcc warnings in http_parser and core_http_client.c. Update ci.yml o use -Werror. Fix gcc warnings in http_parser and core_http_client.c. Update ci.yml to use -Werror. Apr 27, 2021
@paulbartell paulbartell force-pushed the paulbartell/replace-strncpy-fortify-source branch 4 times, most recently from e7a0c2f to 6dc1426 Compare April 28, 2021 01:39
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@abhidixi11 abhidixi11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there is absolute necessity, HTTP parser should not be updated. It should be also tested before updating.

@paulbartell
Copy link
Author

Unless there is absolute necessity, HTTP parser should not be updated. It should be also tested before updating.

The change itself is very minimal and is just to quiet a gcc warning. It is absolutely necessary to do so or we can't enable -Werror and will continue to miss compiler warnings. Here's one of the warnings generated by the library:

/project/aws-iot-device-sdk-embedded-C/libraries/standard/coreHTTP/source/dependency/3rdparty/http_parser/http_parser.h:286:37: error: comma at end of enumerator list [-Werror=pedantic]
  286 | #define HTTP_ERRNO_GEN(n, s) HPE_##n,

@paulbartell paulbartell force-pushed the paulbartell/replace-strncpy-fortify-source branch 3 times, most recently from f966279 to a342513 Compare April 29, 2021 23:12
@paulbartell paulbartell changed the title Fix gcc warnings in http_parser and core_http_client.c. Update ci.yml to use -Werror. Fix gcc warnings in core_http_client.c. Update ci.yml. Apr 29, 2021
run: |
cd build/
cd build
make coverage
Copy link
Contributor

@aggarw13 aggarw13 Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor) What's the purpose of building coverage target instead of just the unit test binaries with the all target when the next step in this job runs test for coverage?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The all target does not run the unit tests, only the coverage target does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the coverage target to build and run the unit tests necessarily. The ctest command takes care of running the unit tests

sudo apt-get install -y cmake lcov
CFLAGS=" --coverage -O0 -Wall -Wextra"
CFLAGS+=" -Werror -Wno-error=pedantic"
CFLAGS+=" -D_FORTIFY_SOURCE=2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about what this configuration and its value does?

@@ -1340,9 +1340,9 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
pBufferCur += fieldLen;

/* Copy the field separator, ": ", into the buffer. */
( void ) strncpy( pBufferCur,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving this here: This was the commit where we changed memcpy to strncpy to satisfy Coverity :
e0ebc00

@paulbartell paulbartell force-pushed the paulbartell/replace-strncpy-fortify-source branch 2 times, most recently from 8fb5bac to 166cbe0 Compare May 11, 2021 17:28
@paulbartell paulbartell force-pushed the paulbartell/replace-strncpy-fortify-source branch from 32b5837 to 4b1ff21 Compare May 11, 2021 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants