From 1977d56caaff40ea9bbf6754b69bec9539a5a969 Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 30 Sep 2016 15:15:50 +0100 Subject: Remove return after no-return situation (and other cleanups). Cleanups: - Fix header guards to not use reserved names. - Avoid name shadowing. - Removed an unused variable found by avoiding name shadowing. --- testing/DHT_test.c | 2 -- testing/Messenger_test.c | 4 ++-- testing/irc_syncbot.c | 16 +++++++--------- testing/nTox.c | 1 - testing/tox_shell.c | 2 -- testing/tox_sync.c | 2 -- 6 files changed, 9 insertions(+), 18 deletions(-) (limited to 'testing') diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c9223546..df029d41 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c @@ -259,6 +259,4 @@ int main(int argc, char *argv[]) print_friendlist(dht); c_sleep(300); } - - return 0; } diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index 3b7715a2..9f56c903 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c @@ -67,7 +67,7 @@ static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type * networking_requesthandler and so cannot take a Messenger * */ static Messenger *m; -static void print_request(Messenger *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) +static void print_request(Messenger *m2, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) { printf("Friend request received from: \n"); printf("ClientID: "); @@ -91,7 +91,7 @@ static void print_request(Messenger *m, const uint8_t *public_key, const uint8_t //if the request contained the message of peace the person is obviously a friend so we add him. { printf("Friend request accepted.\n"); - m_addfriend_norequest(m, public_key); + m_addfriend_norequest(m2, public_key); } } diff --git a/testing/irc_syncbot.c b/testing/irc_syncbot.c index f72339a6..affc0296 100644 --- a/testing/irc_syncbot.c +++ b/testing/irc_syncbot.c @@ -47,9 +47,9 @@ static uint64_t get_monotime_sec(void) static int reconnect(void) { - int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + int new_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sock < 0) { + if (new_sock < 0) { printf("error socket\n"); return -1; } @@ -68,14 +68,14 @@ static int reconnect(void) addr4->sin_port = htons(port); - if (connect(sock, (struct sockaddr *)&addr, addrsize) != 0) { + if (connect(new_sock, (struct sockaddr *)&addr, addrsize) != 0) { printf("error connect\n"); return -1; } - send(sock, SERVER_CONNECT, sizeof(SERVER_CONNECT) - 1, MSG_NOSIGNAL); + send(new_sock, SERVER_CONNECT, sizeof(SERVER_CONNECT) - 1, MSG_NOSIGNAL); - return sock; + return new_sock; } #include "../toxcore/tox.h" @@ -256,9 +256,9 @@ static Tox *init_tox(int argc, char *argv[]) exit(1); } - uint16_t port = atoi(argv[argvoffset + 2]); + uint16_t bootstrap_port = atoi(argv[argvoffset + 2]); unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); - tox_bootstrap(tox, argv[argvoffset + 1], port, binary_string, 0); + tox_bootstrap(tox, argv[argvoffset + 1], bootstrap_port, binary_string, 0); free(binary_string); uint8_t *bin_id = hex_string_to_bin(temp_id); @@ -372,6 +372,4 @@ int main(int argc, char *argv[]) tox_iterate(tox, NULL); usleep(1000 * 50); } - - return 0; } diff --git a/testing/nTox.c b/testing/nTox.c index d620390d..3b24d903 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -1233,7 +1233,6 @@ static void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_n if (file_senders[i].file && file_senders[i].friendnum == friend_number && file_senders[i].filenumber == file_number) { fclose(file_senders[i].file); file_senders[i].file = 0; - char msg[512]; sprintf(msg, "[t] %u file transfer: %u cancelled", file_senders[i].friendnum, file_senders[i].filenumber); new_lines(msg); } diff --git a/testing/tox_shell.c b/testing/tox_shell.c index 7a6678ce..18aad9c7 100644 --- a/testing/tox_shell.c +++ b/testing/tox_shell.c @@ -159,6 +159,4 @@ int main(int argc, char *argv[]) tox_iterate(tox, master); c_sleep(1); } - - return 0; } diff --git a/testing/tox_sync.c b/testing/tox_sync.c index d90024b5..0c91abfd 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c @@ -333,6 +333,4 @@ int main(int argc, char *argv[]) tox_iterate(tox, NULL); c_sleep(1); } - - return 0; } -- cgit v1.2.3