-
Couldn't load subscription status.
- Fork 642
[PR from CLI tool] Fix pointer logging warnings in MQTT library #1109
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
[PR from CLI tool] Fix pointer logging warnings in MQTT library #1109
Conversation
Codecov Report
@@ Coverage Diff @@
## development #1109 +/- ##
===============================================
+ Coverage 96.54% 98.46% +1.91%
===============================================
Files 9 4 -5
Lines 5643 1301 -4342
Branches 641 385 -256
===============================================
- Hits 5448 1281 -4167
+ Misses 9 0 -9
+ Partials 186 20 -166
Continue to review full report at Codecov.
|
| userCallback, | ||
| pTransportInterface->recv, | ||
| pTransportInterface->send ) ); | ||
| LogError( ( "Invalid parameter: getTimeFunction is NULL" ) ); |
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.
What's the purpose in separating these parameters? It seems more repetitive this way, and it doesn't match the condition earlier in this function, at line 1374
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.
The earlier implementation was printing the function pointers under a single if condition so that the reader could detect which of the function pointers is null. However, casting function pointers to void * for printing is not supported by ISO C.
GCC gives the following warning when casting function pointers to void *
/home/ubuntu/Repos/aws-iot-device-sdk-embedded-C/libraries/standard/mqtt/src/mqtt.c:1387:21: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘MQTTGetCurrentTimeFunc_t {aka unsigned int (*)(void)}’ [-Wformat=]
LogError( ( "Invalid parameter: getTimeFunction is NULL: %p", getTimeFunction ) );
^
/home/ubuntu/Repos/aws-iot-device-sdk-embedded-C/demos/logging-stack/logging_stack.h:49:40: note: in definition of macro ‘SdkLog’
#define SdkLog( string ) printf string
^~~~~~
/home/ubuntu/Repos/aws-iot-device-sdk-embedded-C/libraries/standard/mqtt/src/mqtt.c:1387:9: note: in expansion of macro ‘LogError’
LogError( ( "Invalid parameter: getTimeFunction is NULL: %p", getTimeFunction ) );
Fix build warnings with
-Wall -Wextraflags for pointer logging in MQTT files.Description of changes:
(void *)cast for logging non-function pointers(void *)cast of function pointers (Only POSIX does)By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.