From cfb0aa8f2517d3a1ed1f2bf07e72bc3012a1a0da Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 10 Jan 2022 10:57:28 +0000 Subject: [PATCH] cleanup: Remove extra parens around function arguments. --- other/analysis/gen-file.sh | 13 ++++++++----- toxav/bwcontroller.c | 6 +++--- toxav/rtp.c | 4 ++-- toxcore/friend_connection.c | 2 +- toxcore/group.c | 2 +- toxcore/network.c | 4 ++-- toxcore/onion_client.c | 2 +- toxcore/state.c | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/other/analysis/gen-file.sh b/other/analysis/gen-file.sh index bf32c18b..b61e90af 100644 --- a/other/analysis/gen-file.sh +++ b/other/analysis/gen-file.sh @@ -29,22 +29,22 @@ put() { } putmain() { - echo "namespace ${1//[^a-zA-Z0-9_]/_} {" >>amalgamation.cc + NS=$(echo "${1//[^a-zA-Z0-9_]/_}" | sed -e 's/^__*//') + echo "namespace $NS {" >>amalgamation.cc if [ "$SKIP_LINES" = "" ]; then echo "#line 1 \"$1\"" >>amalgamation.cc fi sed -e 's/^int main(/static &/' "$1" >>amalgamation.cc - echo "} // namespace ${1//[^a-zA-Z0-9_]/_}" >>amalgamation.cc + echo "} // namespace $NS" >>amalgamation.cc } callmain() { - echo " call(${1//[^a-zA-Z0-9_]/_}::main, argc, argv);" >>amalgamation.cc + NS=$(echo "${1//[^a-zA-Z0-9_]/_}" | sed -e 's/^__*//') + echo " call($NS::main, argc, argv);" >>amalgamation.cc } : >amalgamation.cc -put auto_tests/check_compat.h - # Include all C and C++ code FIND_QUERY="find . '-(' -name '*.c' -or -name '*.cc' '-)'" # Excludes @@ -52,6 +52,7 @@ FIND_QUERY="$FIND_QUERY -and -not -wholename './_build/*'" FIND_QUERY="$FIND_QUERY -and -not -wholename './super_donators/*'" FIND_QUERY="$FIND_QUERY -and -not -name amalgamation.cc" FIND_QUERY="$FIND_QUERY -and -not -name av_test.c" +FIND_QUERY="$FIND_QUERY -and -not -name cracker.c" FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c" FIND_QUERY="$FIND_QUERY -and -not -name trace.cc" FIND_QUERY="$FIND_QUERY -and -not -name version_test.c" @@ -64,6 +65,8 @@ readarray -t FILES <<<"$(eval "$FIND_QUERY")" grep -E -v '||>amalgamation.cc +put auto_tests/check_compat.h + echo 'namespace {' >>amalgamation.cc for i in "${FILES[@]}"; do if ! grep -q '^int main(' "$i"; then diff --git a/toxav/bwcontroller.c b/toxav/bwcontroller.c index da1e8ee7..cdc1cdc8 100644 --- a/toxav/bwcontroller.c +++ b/toxav/bwcontroller.c @@ -136,7 +136,7 @@ static void send_update(BWController *bwc) if (bwc->cycle.lost) { LOGGER_DEBUG(bwc->m->log, "%p Sent update rcv: %u lost: %u percent: %f %%", (void *)bwc, bwc->cycle.recv, bwc->cycle.lost, - (((double) bwc->cycle.lost / (bwc->cycle.recv + bwc->cycle.lost)) * 100.0)); + ((double)bwc->cycle.lost / (bwc->cycle.recv + bwc->cycle.lost)) * 100.0); uint8_t bwc_packet[sizeof(struct BWCMessage) + 1]; size_t offset = 0; @@ -178,9 +178,9 @@ static int on_update(BWController *bwc, const struct BWCMessage *msg) if (lost && bwc->mcb) { LOGGER_DEBUG(bwc->m->log, "recved: %u lost: %u percentage: %f %%", recv, lost, - (((double) lost / (recv + lost)) * 100.0)); + ((double)lost / (recv + lost)) * 100.0); bwc->mcb(bwc, bwc->friend_number, - ((float) lost / (recv + lost)), + (float)lost / (recv + lost), bwc->mcb_user_data); } diff --git a/toxav/rtp.c b/toxav/rtp.c index 071d1a2a..731d86d8 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c @@ -320,7 +320,7 @@ static void update_bwc_values(const Logger *log, RTPSession *session, const stru if (received_length_full < data_length_full) { LOGGER_DEBUG(log, "BWC: full length=%u received length=%d", data_length_full, received_length_full); - bwc_add_lost(session->bwc, (data_length_full - received_length_full)); + bwc_add_lost(session->bwc, data_length_full - received_length_full); } } } @@ -479,7 +479,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t return -1; } - LOGGER_DEBUG(m->log, "header.pt %d, video %d", (uint8_t)header.pt, (RTP_TYPE_VIDEO % 128)); + LOGGER_DEBUG(m->log, "header.pt %d, video %d", (uint8_t)header.pt, RTP_TYPE_VIDEO % 128); // The sender uses the new large-frame capable protocol and is sending a // video packet. diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 74b3be84..00b65f34 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -932,7 +932,7 @@ void do_friend_connections(Friend_Connections *fr_c, void *userdata) if (friend_con->dht_lock) { if (friend_new_connection(fr_c, i) == 0) { set_direct_ip_port(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->dht_ip_port, 0); - connect_to_saved_tcp_relays(fr_c, i, (MAX_FRIEND_TCP_CONNECTIONS / 2)); /* Only fill it half up. */ + connect_to_saved_tcp_relays(fr_c, i, MAX_FRIEND_TCP_CONNECTIONS / 2); /* Only fill it half up. */ } } } else if (friend_con->status == FRIENDCONN_STATUS_CONNECTED) { diff --git a/toxcore/group.c b/toxcore/group.c index fb2b94c3..277e982e 100644 --- a/toxcore/group.c +++ b/toxcore/group.c @@ -2202,7 +2202,7 @@ static unsigned int send_peers(Group_Chats *g_c, const Group_c *g, int friendcon || (p - response_packet) + sizeof(uint16_t) + CRYPTO_PUBLIC_KEY_SIZE * 2 + 1 + g->group[i].nick_len > sizeof(response_packet)) { if (send_packet_group_peer(g_c->fr_c, friendcon_id, PACKET_ID_DIRECT_CONFERENCE, group_num, response_packet, - (p - response_packet))) { + p - response_packet)) { sent = i; } else { return sent; diff --git a/toxcore/network.c b/toxcore/network.c index 2898f056..81a9ad33 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -499,12 +499,12 @@ static void loglogdata(const Logger *log, const char *message, const uint8_t *bu net_kill_strerror(strerror); } else if ((res > 0) && ((size_t)res <= buflen)) { LOGGER_TRACE(log, "[%2u] %s %3u%c %s:%u (%u: %s) | %04x%04x", - buffer[0], message, min_u16(res, 999), ((size_t)res < buflen ? '<' : '='), + buffer[0], message, min_u16(res, 999), (size_t)res < buflen ? '<' : '=', ip_ntoa(&ip_port.ip, ip_str, sizeof(ip_str)), net_ntohs(ip_port.port), 0, "OK", data_0(buflen, buffer), data_1(buflen, buffer)); } else { /* empty or overwrite */ LOGGER_TRACE(log, "[%2u] %s %u%c%u %s:%u (%u: %s) | %04x%04x", - buffer[0], message, res, (!res ? '!' : '>'), buflen, + buffer[0], message, res, !res ? '!' : '>', buflen, ip_ntoa(&ip_port.ip, ip_str, sizeof(ip_str)), net_ntohs(ip_port.port), 0, "OK", data_0(buflen, buffer), data_1(buflen, buffer)); } diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 044a27ba..7d4cc0a5 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -1182,7 +1182,7 @@ static int send_dhtpk_announce(Onion_Client *onion_c, uint16_t friend_num, uint8 net_pack_u64(data + 1, no_replay); memcpy(data + 1 + sizeof(uint64_t), dht_get_self_public_key(onion_c->dht), CRYPTO_PUBLIC_KEY_SIZE); Node_format nodes[MAX_SENT_NODES]; - uint16_t num_relays = copy_connected_tcp_relays(onion_c->c, nodes, (MAX_SENT_NODES / 2)); + uint16_t num_relays = copy_connected_tcp_relays(onion_c->c, nodes, MAX_SENT_NODES / 2); uint16_t num_nodes = closelist_nodes(onion_c->dht, &nodes[num_relays], MAX_SENT_NODES - num_relays); num_nodes += num_relays; int nodes_len = 0; diff --git a/toxcore/state.c b/toxcore/state.c index d546c001..a3176813 100644 --- a/toxcore/state.c +++ b/toxcore/state.c @@ -34,7 +34,7 @@ int state_load(const Logger *log, state_load_cb *state_load_callback, void *oute return -1; } - if (lendian_to_host16((cookie_type >> 16)) != cookie_inner) { + if (lendian_to_host16(cookie_type >> 16) != cookie_inner) { /* something is not matching up in a bad way, give up */ LOGGER_ERROR(log, "state file garbled: %04x != %04x", cookie_type >> 16, cookie_inner); return -1;