-
Notifications
You must be signed in to change notification settings - Fork 168
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 printf warnings #1222
Merged
Merged
Fix printf warnings #1222
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ntohl() returns a u32, which is defined as an unsigned long in GCC. > /source/FreeRTOS_IPv4.c:442:52: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat=-Wformat=8;;] > 442 | FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %xip without CRC dropped\n", > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > /build/src/FreeRTOSIPConfig.h:75:12: note: in definition of macro 'FreeRTOS_printf' > 75 | printf X > | ^ > /source/FreeRTOS_IPv4.c:442:88: note: format string is defined here > 442 | FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %xip without CRC dropped\n", > | ~^ > | | > | unsigned int > | %lx
ntohl() returns a u32, which is defined as an unsigned int in Clang. So we need to explicitely upper cast it into unsigned long. Fixes this Clang warnining: > /source/FreeRTOS_IPv4.c:443:52: warning: format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int') [-Wformat] > 442 | FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %lxip without CRC dropped\n", > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | %x > 443 | FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > /source/include/FreeRTOS_IP.h:252:32: note: expanded from macro 'FreeRTOS_ntohl' > 252 | #define FreeRTOS_ntohl( x ) FreeRTOS_htonl( x ) > | ^ > /source/include/FreeRTOS_IP.h:233:5: note: expanded from macro 'FreeRTOS_htonl' > 233 | ( \ > | ^ > /build/src/FreeRTOSIPConfig.h:75:12: note: expanded from macro 'FreeRTOS_printf' > 75 | printf X > | ^
Fixes Clang warnings of this type: > /source/FreeRTOS_DHCP.c:405:87: warning: format specifies type 'unsigned long' but the argument has type 'TickType_t' (aka 'unsigned int') [-Wformat] > 405 | FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", EP_DHCPData.xDHCPTxPeriod ) ); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | %u > /source/FreeRTOS_DHCP.c:59:33: note: expanded from macro 'EP_DHCPData' > 59 | #define EP_DHCPData pxEndPoint->xDHCPData /**< Temporary define to make /single source similar to /multi version. */ > | ^ > /build/src/FreeRTOSIPConfig.h:60:12: note: expanded from macro 'FreeRTOS_debug_printf' > 60 | printf X > | ^
ig15
approved these changes
Feb 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to remove $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wno-format>
from CMakeLists.txt or this will just keep happening.
Sorry. That comment was meant for the kernel repository.
tony-josi-aws
approved these changes
Feb 3, 2025
Thanks for contributing to FreeRTOS+TCP. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Handle correctly types when printing.
Description
When compiling, I had some warnings regarding printf. I fixed them by using the correct types.
Test Steps
Compile using GCC or Clang with
-Wformat
.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.