-
Notifications
You must be signed in to change notification settings - Fork 211
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
PROTON-2714: add annotations for printf-like format strings and fix linux compiler warnings #397
PROTON-2714: add annotations for printf-like format strings and fix linux compiler warnings #397
Conversation
367decd
to
03a5c0b
Compare
33c6c02
to
bfcf355
Compare
@@ -43,7 +43,7 @@ static pn_event_t *batch_next(pn_connection_driver_t *d) { | |||
/* Log the next event that will be processed */ | |||
pn_event_t *next = pn_collector_next(d->collector); | |||
if (next && PN_SHOULD_LOG(&d->transport->logger, PN_SUBSYSTEM_EVENT, PN_LEVEL_DEBUG)) { | |||
pni_logger_log_msg_inspect(&d->transport->logger, PN_SUBSYSTEM_EVENT, PN_LEVEL_DEBUG, next, ""); | |||
pni_logger_log_msg_inspect(&d->transport->logger, PN_SUBSYSTEM_EVENT, PN_LEVEL_DEBUG, next, "%s", ""); |
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.
there is only this one line where the annotations lead to siliness needed not to generate a warning (empty formatting string on gcc generates warning)
@@ -1034,7 +1037,7 @@ static ssize_t process_input_ssl( pn_transport_t *transport, unsigned int layer, | |||
transport->present_layers |= LAYER_SSL; | |||
} | |||
|
|||
ssl_log( transport, PN_LEVEL_TRACE, "process_input_ssl( data size=%d )",available ); | |||
ssl_log( transport, PN_LEVEL_TRACE, "process_input_ssl( data size=%zu )",available ); |
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.
this may rather need the portable format string macros, not sure if necessary
c/src/core/logger.c
Outdated
@@ -201,7 +201,7 @@ void pni_logger_log_raw(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_lo | |||
const char *start = &bytes.start[bytes.size-size]; | |||
for (unsigned i = 0; i < size; i+=16) { | |||
pn_fixed_string_t out = pn_fixed_string(buf, sizeof(buf)); | |||
pn_fixed_string_addf(&out, "%04x/%04x: ", i, size); | |||
pn_fixed_string_addf(&out, "%04x/%04zx: ", i, size); |
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.
this may rather need the portable format string macros, not sure if necessary
It looks that msvc wants its annotation on both declaration and definition,
edit: https://learn.microsoft.com/en-us/cpp/code-quality/c28251?view=msvc-170 |
But it seems to be good enough to produce reports
|
I feel that we had these annotations in the original proton code base - I wonder where they went? |
They are still there, but only applied to two of the functions. I'm rewriting those here to use the macros from Facebook.
Sure, I only decided to raise the PR now because otherwise I might forget to do it after the release. It found two broken format strings on Linux and quite a lot on Windows, but I guess this is not a release blocker. All about size_t printing; did not investigate, but it looks like somebody was switching to larger type and missed formatting strings while making the change? |
|
||
// warn format placeholders | ||
|
||
// NOTE: this will only do checking in msvc with versions that support /analyze |
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.
It only seems to check when one actually uses /analyze
, using the highest tier of latest visual studio does not show any warnings from this without that option. Neither /W4
helps any.
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.
and the checks get lost in the noise very easily
4d9a529
to
fb6e82f
Compare
fb6e82f
to
2b7aa94
Compare
Sorry for creating the duplicate, I did not remember I already created a PR for this. It's actually good, since I already have it (mostly) reviewed, and the time has come preparing for next release, so it is a good time to do this. |
No description provided.