-
Notifications
You must be signed in to change notification settings - Fork 380
sys/log: add format attribute to modlog_printf prototype #3530
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
base: master
Are you sure you want to change the base?
Conversation
|
Note that there is pre-existing usage of |
1e70331 to
acedf5a
Compare
|
@ehaas I think once the nimble PR is merged, the CI issues will get fixed. Let's wait for that. |
sjanc
left a comment
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 setup is giving you those errors where int32_t is long int? we could add this to CI to avoid similar issues in future
net/oic/src/port/mynewt/ip_adaptor.c
Outdated
| rc = mn_sendto(oc_ucast6, n, (struct mn_sockaddr *) &to); | ||
| if (rc != 0) { | ||
| OC_LOG_ERROR("Failed to send buffer %u on itf %d\n", | ||
| OC_LOG_ERROR("Failed to send buffer %u on itf %" PRIu32 "\n", |
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.
I'm really not a huge fan of PRI syntax... especially that it leads to inconsistent print formatting, eg here you don't use PRIu16 for omp_len
what do you think on using %u here and casting msin6_scope_id to (unsigned int) ?
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.
Updated; I also find the PRI syntax pretty ugly.
| */ | ||
| void modlog_printf(uint8_t module, uint8_t level, const char *msg, ...); | ||
| void modlog_printf(uint8_t module, uint8_t level, const char *msg, ...) | ||
| __attribute((format(printf, 3, 4))); |
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.
modlog.h is included in a lot of modules in core, only osdp and oic require fixes for this to be enabled?
maybe it should be under MYNEWT_VAL (at least for time being) so that no unexpected build errors are introduced?
(especially that currently we always enable Werror - which we should make opt-in option anyway)
yeah, I guess any reasonable compiler supports this extension :) |
Here is a repro on arm-none-eabi-gcc 8.3.1: https://godbolt.org/z/sTnPahqE5 |
Add format(printf) attribute to modlog_printf to enable compile-time checking that format strings match arguments. Note that this will cause incorrect modlog_printf usage which previously compiled successfully, to no longer compile.
acedf5a to
de2fb82
Compare
sjanc
left a comment
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.
looks ok to me but please fix compliance issues reported
I guess Nimble PR also should be updated to use cast instead PRI and this should be ready for merging
Add format(printf) attribute to modlog_printf to enable compile-time checking that format strings match arguments.
Note that this will cause incorrect modlog_printf usage which previously compiled successfully, to no longer compile.