mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Avoid implicit boolean and floating point conversions in decls.
Also avoid implicit enum-to-int.
This commit is contained in:
parent
598a365e1f
commit
cc045d6343
|
@ -1 +1 @@
|
|||
e73d3dce83fd0dd2bc5f5517692e84fb64b856201e22fcbfc59dc84fc22e3ee6 /usr/local/bin/tox-bootstrapd
|
||||
06d4c48fbc0727ccfb6a48ff6784558f8e9c377f9d29786fbf206810e9b76788 /usr/local/bin/tox-bootstrapd
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
case ONION_CONNECTION_STATUS_TCP:
|
||||
return TOX_CONNECTION_TCP;
|
||||
|
||||
case ONION_CONNECTION_STATUS_UDP:
|
||||
return TOX_CONNECTION_UDP;
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
return TOX_CONNECTION_TCP;
|
||||
}
|
||||
|
||||
return TOX_CONNECTION_NONE;
|
||||
LOGGER_FATAL(tox->m->log, "impossible return value: %d", ret);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user