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

Matching format specifies type to argument type to eliminate compile … #521

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

ZexiLiu
Copy link
Contributor

@ZexiLiu ZexiLiu commented Jul 18, 2024

…warnings

format specifies type 'unsigned long' but the argument has type 'ulong' (aka 'unsigned long long').

@@ -1151,7 +1151,7 @@ void raft_server::check_leadership_transfer() {
if (peer_elem->get_matched_idx() + params->stale_log_gap_ <
cur_commit_idx) {
// This peer is lagging behind.
p_tr("peer %d is lagging behind, %lu < %lu",
p_tr("peer %d is lagging behind, %llu < %llu",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use PRIu64. This symbol is different according to the platform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are many %lu, %llu, %d use case across the whole repo, but I am only fixing this line because it has warning during compile.

I fixed it to use PRIu64.

Copy link
Contributor

@greensky00 greensky00 Jul 18, 2024

Choose a reason for hiding this comment

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

%d probably be ok, but 64-bit integers should be replaced. The whole project was re-visited a couple of years ago, but if there are still missing ones, we need to fix them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

~ grep -rn "%l" .                                                                               
./fix_format.hxx:20:    replace_all(format_string, "%ld", "%" PRId64); \
./fix_format.hxx:21:    replace_all(format_string, "%lu", "%" PRIu64); \
./asio_service.cxx:336:                      "due to error %d, %s, ref count %ld",

We don't need to care about ./fix_format.hxx, the %ld in ./asio_service.cxx is correct, I think that is all the case.

@@ -1160,7 +1160,7 @@ void raft_server::check_leadership_transfer() {
uint64_t last_resp_ms = peer_elem->get_resp_timer_us() / 1000;
if (last_resp_ms > election_lower) {
// This replica is not responding.
p_tr("peer %d is not responding, %lu ms ago",
p_tr("peer %d is not responding, %llu ms ago",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@greensky00 greensky00 merged commit f4c8e05 into eBay:master Jul 22, 2024
1 check 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