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

swaglog: enable type-checked against format string. #29096

Merged
merged 5 commits into from
Aug 1, 2023

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Jul 22, 2023

enable type-check & correct format string.

added a macro SWAG_LOG_CHECK_FMT to causes the compiler to check the arguments in calls to cloudlog for consistency with the printf style format string argument:


system/ubloxd/ublox_msg.cc:393:57: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
      LOGE("SV_ID != SLOT_NUMBER: %d %d", msg->sv_id(), data->n());
                                     ~~                 ^~~~~~~~~
                                     %lu

@deanlee deanlee marked this pull request as draft July 22, 2023 13:26
@deanlee
Copy link
Contributor Author

deanlee commented Jul 22, 2023

failed to pass the checks. need correct the format string in rednose : commaai/rednose#31

@deanlee deanlee force-pushed the log_check_fmt branch 5 times, most recently from 4e516e8 to a88a75c Compare July 22, 2023 19:08
@deanlee deanlee marked this pull request as ready for review July 22, 2023 20:05
Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

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

can you open the matching rednose PR?

@@ -390,7 +390,7 @@ kj::Array<capnp::word> UbloxMsgParser::parse_glonass_ephemeris(ubx_t::rxm_sfrbx_
eph.setP4(data->p4());
eph.setSvURA(glonass_URA_lookup.at(data->f_t()));
if (msg->sv_id() != data->n()) {
LOGE("SV_ID != SLOT_NUMBER: %d %d", msg->sv_id(), data->n());
LOGE("SV_ID != SLOT_NUMBER: %d %" PRIu64, msg->sv_id(), data->n());
Copy link
Contributor

Choose a reason for hiding this comment

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

why not llu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use llu will report error on my laptop. the uint64_t is not the same as unsigned long long. https://stackoverflow.com/questions/32198368/unsigned-long-long-conflict-with-uint64-t

the PRIu64 can correctly format uint64_t as lu or llu on different platforms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

another way is use llu, and convert uint64_t to (unsigned long long):

LOGE("SV_ID != SLOT_NUMBER: %d %llu", msg->sv_id(), (unsigned long long)data->n());

@deanlee
Copy link
Contributor Author

deanlee commented Jul 23, 2023

can you open the matching rednose PR?

opened at : commaai/rednose#31

@adeebshihadeh adeebshihadeh merged commit 940954c into commaai:master Aug 1, 2023
20 checks passed
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.

2 participants