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: Remove extra parens around function arguments. #1865

Merged
merged 1 commit into from
Jan 12, 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
13 changes: 8 additions & 5 deletions other/analysis/gen-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@ 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
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"
Expand All @@ -64,6 +65,8 @@ readarray -t FILES <<<"$(eval "$FIND_QUERY")"
grep -E -v '<win|<ws|<iphlp|<libc|<mach/|<crypto_|<randombytes|<u.h>|<sys/filio|<stropts.h>|<linux'
done) | sort -u >>amalgamation.cc

put auto_tests/check_compat.h

echo 'namespace {' >>amalgamation.cc
for i in "${FILES[@]}"; do
if ! grep -q '^int main(' "$i"; then
Expand Down
6 changes: 3 additions & 3 deletions toxav/bwcontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions toxav/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion toxcore/friend_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion toxcore/onion_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down