-
Notifications
You must be signed in to change notification settings - Fork 291
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
cleanup: Remove implicit bool conversions. #2621
Conversation
698c4c1
to
0185de1
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2621 +/- ##
==========================================
- Coverage 73.71% 73.57% -0.15%
==========================================
Files 148 148
Lines 30424 30420 -4
==========================================
- Hits 22428 22382 -46
- Misses 7996 8038 +42 ☔ View full report in Codecov by Sentry. |
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.
Reviewed 19 of 19 files at r1, all commit messages.
Reviewable status: 0 of 1 approvals obtained (waiting on @iphydf)
toxcore/group_chats.c
line 3918 at r1 (raw file):
// the topic version should never change when the topic lock is disabled except when // the founder changes the topic prior to enabling the lock if (peer->role != GR_FOUNDER || topic_info->version != chat->shared_state.topic_lock + 1) {
Why is this being changed? While I can see people having a preference for one or the other, personally I find that the former logic is easier to parse.
toxcore/group_moderation.c
line 553 at r1 (raw file):
if (moderation->shared_state_version > 0) { if ((creds->version < moderation->sanctions_creds.version) && (creds->version != 0 || moderation->sanctions_creds.version != UINT32_MAX)) {
Same question as above.
toxcore/net_crypto.c
line 2730 at r1 (raw file):
/* When switching from TCP to UDP, don't change the packet send rate for CONGESTION_EVENT_TIMEOUT ms. */ if (!(direct_connected && conn->last_tcp_sent + CONGESTION_EVENT_TIMEOUT > temp_time)) {
Same as above
toxcore/onion_client.c
line 1936 at r1 (raw file):
&& (paths->last_path_used_times[pathnum] == 0 || !mono_time_is_timeout( mono_time, paths->last_path_used[pathnum], ONION_PATH_TIMEOUT));
This entire clause is insane. We should think about refactoring it.
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.
Looked only over the bootstrap daemon changes. Some changes I'm happy with, e.g. the functions returning 0/1 changing to return false/true is a very welcome change, but some I'm not happy with, like if (!pointer)
-> if (pointer == nullptr)
and some others.
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @JFreegman)
toxcore/group_chats.c
line 3918 at r1 (raw file):
Previously, JFreegman wrote…
Why is this being changed? While I can see people having a preference for one or the other, personally I find that the former logic easier to parse.
Done.
toxcore/group_moderation.c
line 553 at r1 (raw file):
Previously, JFreegman wrote…
Same question as above.
Done.
toxcore/net_crypto.c
line 2730 at r1 (raw file):
Previously, JFreegman wrote…
Same as above
Done.
toxcore/onion_client.c
line 1936 at r1 (raw file):
Previously, JFreegman wrote…
This entire clause is insane. We should think about refactoring it.
I looked at it a bit. That raised more questions than I want to resolve for this PR.
Please mark the ones you're not happy with and want reverted. The |
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.
Reviewed 9 of 19 files at r1, 10 of 10 files at r2, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf and @JFreegman)
other/bootstrap_daemon/src/config.c
line 407 at r2 (raw file):
free(bs_public_key_bin); if (address_resolved == 0) {
This was more readable before.
How about the following?
bool address_resolved;
...
address_resolved = dht_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), bs_public_key_bin) == 0;
...
if (!address_resolved) {
I would prefer to not have this == 0
and let do the int-to-bool conversion do the trick, but I take it you want an explicit conversion.
toxcore/onion_client.c
line 1928 at r2 (raw file):
non_null() static bool path_is_stable(const Mono_Time *mono_time, const Onion_Client_Paths *paths, uint32_t pathnum, const Onion_Node *node)
Pad the arguments with spaces to match where they start on the 1st line?
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.
Reviewed 10 of 10 files at r2, all commit messages.
Reviewable status: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @iphydf)
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.
Reviewable status: complete! 1 change requests, 1 of 1 approvals obtained (waiting on @JFreegman and @nurupo)
other/bootstrap_daemon/src/config.c
line 407 at r2 (raw file):
Previously, nurupo wrote…
This was more readable before.
How about the following?
bool address_resolved; ... address_resolved = dht_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), bs_public_key_bin) == 0; ... if (!address_resolved) {
I would prefer to not have this
== 0
and let do the int-to-bool conversion do the trick, but I take it you want an explicit conversion.
Changed dht_bootstrap_from_address to return bool, instead.
toxcore/onion_client.c
line 1928 at r2 (raw file):
Previously, nurupo wrote…
Pad the arguments with spaces to match where they start on the 1st line?
Tell that to astyle and/or clang-format.
c765017
to
6303227
Compare
Restyled astyle is fixed now.
Somehow I can't review just the first commit in Reviewable, in "Review each commit separately" mode each commit should be a separate revision, yet the DHT.h changes somehow got lumped together with the formatting changes into r3 :\ |
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.
Reviewable status: complete! 2 of 1 approvals obtained (waiting on @iphydf and @JFreegman)
toxcore/onion_client.c
line 1928 at r2 (raw file):
Previously, iphydf wrote…
Tell that to astyle and/or clang-format.
I noticed the other function in that file were doing that, so pointed it out.
Looks like this has been fixed now that the code was astyled.
I guess the "Review each commit separately" mode just doesn't work, it's still in the "combine commits" mode, and it put both the code formatting 1st commit + the updated 2nd commit as rev3, so I'm unable to see what you changed since my last review as the 1st commit clutters all of the changes I'm looking for -- I want to ignore the 1st commit and see only 2nd commit changes since the last time. So annoying. Reviewable is great when it works, but annoying when it doesn't. Had to manually re-review the entire 2nd commit. |
This change is