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

cleanup: Avoid implicit boolean and floating point conversions in decls. #2056

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e73d3dce83fd0dd2bc5f5517692e84fb64b856201e22fcbfc59dc84fc22e3ee6 /usr/local/bin/tox-bootstrapd
06d4c48fbc0727ccfb6a48ff6784558f8e9c377f9d29786fbf206810e9b76788 /usr/local/bin/tox-bootstrapd
2 changes: 1 addition & 1 deletion toxcore/TCP_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ static Socket new_listening_TCP_socket(const Logger *logger, Family family, uint
return net_invalid_socket;
}

int ok = set_socket_nonblock(sock);
bool ok = set_socket_nonblock(sock);

if (ok && net_family_is_ipv6(family)) {
ok = set_socket_dualstack(sock);
Expand Down
2 changes: 1 addition & 1 deletion toxcore/net_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ static void send_crypto_packets(Net_Crypto *c)
}

if ((PACKET_COUNTER_AVERAGE_INTERVAL + conn->packet_counter_set) < temp_time) {
const double dt = temp_time - conn->packet_counter_set;
const double dt = (double)(temp_time - conn->packet_counter_set);

conn->packet_recv_rate = (double)conn->packet_counter / (dt / 1000.0);
conn->packet_counter = 0;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION

if (net_family_is_ipv6(ip->family)) {
const int is_dualstack = set_socket_dualstack(temp->sock);
const bool is_dualstack = set_socket_dualstack(temp->sock);
LOGGER_DEBUG(log, "Dual-stack socket: %s",
is_dualstack ? "enabled" : "Failed to enable, won't be able to receive from/send to IPv4 addresses");
/* multicast local nodes */
Expand Down
4 changes: 2 additions & 2 deletions toxcore/onion_announce.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ static int cmp_entry(const void *a, const void *b)
const Onion_Announce_Entry entry2 = cmp2->entry;
const uint8_t *cmp_public_key = cmp1->base_public_key;

const int t1 = mono_time_is_timeout(cmp1->mono_time, entry1.time, ONION_ANNOUNCE_TIMEOUT);
const int t2 = mono_time_is_timeout(cmp1->mono_time, entry2.time, ONION_ANNOUNCE_TIMEOUT);
const bool t1 = mono_time_is_timeout(cmp1->mono_time, entry1.time, ONION_ANNOUNCE_TIMEOUT);
const bool t2 = mono_time_is_timeout(cmp1->mono_time, entry2.time, ONION_ANNOUNCE_TIMEOUT);

if (t1 && t2) {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions toxcore/onion_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ static int onion_client_cmp_entry(const void *a, const void *b)
const Onion_Node entry2 = cmp2->entry;
const uint8_t *cmp_public_key = cmp1->base_public_key;

const int t1 = onion_node_timed_out(&entry1, cmp1->mono_time);
const int t2 = onion_node_timed_out(&entry2, cmp2->mono_time);
const bool t1 = onion_node_timed_out(&entry1, cmp1->mono_time);
const bool t2 = onion_node_timed_out(&entry2, cmp2->mono_time);

if (t1 && t2) {
return 0;
Expand Down
17 changes: 10 additions & 7 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,18 +828,21 @@ Tox_Connection tox_self_get_connection_status(const Tox *tox)
{
assert(tox != nullptr);
lock(tox);
const unsigned int ret = onion_connection_status(tox->m->onion_c);
const Onion_Connection_Status ret = onion_connection_status(tox->m->onion_c);
unlock(tox);

if (ret == 2) {
return TOX_CONNECTION_UDP;
}
switch (ret) {
case ONION_CONNECTION_STATUS_NONE:
return TOX_CONNECTION_NONE;

if (ret == 1) {
return TOX_CONNECTION_TCP;
case ONION_CONNECTION_STATUS_TCP:
return TOX_CONNECTION_TCP;

case ONION_CONNECTION_STATUS_UDP:
return TOX_CONNECTION_UDP;
}

return TOX_CONNECTION_NONE;
LOGGER_FATAL(tox->m->log, "impossible return value: %d", ret);
}


Expand Down