summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zero <zero@cpp.edu>2016-12-02 04:37:23 -0800
committerDavid Zero <zero@cpp.edu>2017-01-04 13:44:39 -0800
commitf3469070fe899e8e4fd88665386a55bad9f77cd8 (patch)
treec24743d266d3a8593792ef3e8661006cb283368a
parent535b8238fd191710e1e8864f302fba5a02f52b1d (diff)
Portability fixes
- CFLAG gnu99 was changed to c99. - CXXFLAG c++98 was changed to c++11. - CFLAG -pedantic-errors was added so that non-ISO C now throws errors. - _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3 and c99 definitions in modules that required them. - Fixed tests (and bootstrap daemon logging) that were failing due to the altered build flags. - Avoid string suffix misinterpretation; explicit narrowing conversion. - Misc. additions to .gitignore to make sure build artifacts don't wind up in version control.
-rw-r--r--.gitignore8
-rw-r--r--CMakeLists.txt15
-rw-r--r--auto_tests/TCP_test.c2
-rw-r--r--auto_tests/conference_test.c8
-rw-r--r--auto_tests/dht_test.c2
-rw-r--r--auto_tests/network_test.c4
-rw-r--r--auto_tests/onion_test.c2
-rw-r--r--auto_tests/save_friend_test.c3
-rw-r--r--auto_tests/tox_many_tcp_test.c2
-rw-r--r--auto_tests/tox_many_test.c2
-rw-r--r--auto_tests/tox_test.c2
-rw-r--r--auto_tests/toxav_basic_test.c2
-rw-r--r--auto_tests/toxav_many_test.c2
-rw-r--r--other/DHT_bootstrap.c2
-rw-r--r--other/bootstrap_daemon/src/log.c19
-rw-r--r--other/bootstrap_daemon/src/tox-bootstrapd.c2
-rw-r--r--testing/DHT_test.c2
-rw-r--r--testing/Messenger_test.c2
-rw-r--r--testing/av_test.c2
-rw-r--r--testing/irc_syncbot.c9
-rw-r--r--testing/misc_tools.c1
-rw-r--r--testing/tox_shell.c2
-rw-r--r--testing/tox_sync.c11
-rw-r--r--toxcore/TCP_server.c4
-rw-r--r--toxcore/network.c2
-rw-r--r--toxcore/tox.c2
-rw-r--r--toxcore/util.c2
27 files changed, 92 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 2a82d308..14dcced7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,9 @@ install_manifest.txt
21tags 21tags
22Makefile.in 22Makefile.in
23CMakeLists.txt.user 23CMakeLists.txt.user
24DartConfiguration.tcl
25CTestTestfile.cmake
26*.pc
24 27
25# Testing 28# Testing
26testing/data 29testing/data
@@ -40,6 +43,9 @@ testing/data
40*.app 43*.app
41*.la 44*.la
42 45
46# Libraries
47*.so
48
43# Misc (?) 49# Misc (?)
44m4/* 50m4/*
45configure 51configure
@@ -51,8 +57,6 @@ config.log
51config.status 57config.status
52stamp-h1 58stamp-h1
53autom4te.cache 59autom4te.cache
54libtoxcore.pc
55libtoxav.pc
56libtool 60libtool
57.deps 61.deps
58.libs 62.libs
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 402b74e0..e9888601 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,22 +56,21 @@ macro(add_flag flag)
56 add_cflag(${flag}) 56 add_cflag(${flag})
57 add_cxxflag(${flag}) 57 add_cxxflag(${flag})
58endmacro() 58endmacro()
59
60# Set standard version for compiler.
61add_cflag("-std=c99")
62add_cxxflag("-std=c++11")
63
64# Error on non-ISO C.
65add_cflag("-pedantic-errors")
59 66
60option(WARNINGS "Enable additional compiler warnings" ON) 67option(WARNINGS "Enable additional compiler warnings" ON)
61if(WARNINGS) 68if(WARNINGS)
62 # Set standard version for compiler.
63 add_cflag("-std=gnu99")
64 add_cxxflag("-std=c++98")
65
66 # Add all warning flags we can. 69 # Add all warning flags we can.
67 add_flag("-Wall") 70 add_flag("-Wall")
68 add_flag("-Wextra") 71 add_flag("-Wextra")
69 add_flag("-Weverything") 72 add_flag("-Weverything")
70 73
71 # -pedantic only for C, because in C++ we want to allow the GNU/C99 extension
72 # of having a comma at the end of an enumerator list.
73 add_cflag("-pedantic")
74
75 # Disable specific warning flags for both C and C++. 74 # Disable specific warning flags for both C and C++.
76 add_flag("-Wno-cast-align") 75 add_flag("-Wno-cast-align")
77 add_flag("-Wno-conversion") 76 add_flag("-Wno-conversion")
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index d9013378..6a439261 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -1,3 +1,5 @@
1#define _XOPEN_SOURCE 600
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index aa2f8e13..36707e0f 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -1,6 +1,8 @@
1/* Auto Tests: Conferences. 1/* Auto Tests: Conferences.
2 */ 2 */
3 3
4#define _XOPEN_SOURCE 600
5
4#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
5#include "config.h" 7#include "config.h"
6#endif 8#endif
@@ -175,7 +177,7 @@ group_test_restart:
175 * Either way in this case it's fine */ 177 * Either way in this case it's fine */
176 if (peer_count != NUM_GROUP_TOX) { 178 if (peer_count != NUM_GROUP_TOX) {
177 ++test_run; 179 ++test_run;
178 printf("\tError starting up the first group (peer_count %"PRIu32" != %d, test_run = %d)\n", peer_count, NUM_GROUP_TOX, 180 printf("\tError starting up the first group (peer_count %" PRIu32 " != %d, test_run = %d)\n", peer_count, NUM_GROUP_TOX,
179 test_run); 181 test_run);
180 182
181 for (j = 0; j < NUM_GROUP_TOX; ++j) { 183 for (j = 0; j < NUM_GROUP_TOX; ++j) {
@@ -194,7 +196,7 @@ group_test_restart:
194 * important again. 196 * important again.
195 */ 197 */
196 ck_assert_msg(peer_count == NUM_GROUP_TOX, "\n\tBad number of group peers (pre check)." 198 ck_assert_msg(peer_count == NUM_GROUP_TOX, "\n\tBad number of group peers (pre check)."
197 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %"PRIu32"\n\n", 199 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n",
198 NUM_GROUP_TOX, i, peer_count); 200 NUM_GROUP_TOX, i, peer_count);
199 201
200 uint8_t title[2048]; 202 uint8_t title[2048];
@@ -241,7 +243,7 @@ group_test_restart:
241 for (i = 0; i < (k - 1); ++i) { 243 for (i = 0; i < (k - 1); ++i) {
242 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL); 244 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL);
243 ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)." 245 ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)."
244 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %"PRIu32"\n\n", 246 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n",
245 (k - 1), i, peer_count); 247 (k - 1), i, peer_count);
246 } 248 }
247 } 249 }
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c
index 9cec1643..633e7002 100644
--- a/auto_tests/dht_test.c
+++ b/auto_tests/dht_test.c
@@ -1,3 +1,5 @@
1#define _XOPEN_SOURCE 600
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index 783f3f7b..ca918778 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -114,8 +114,8 @@ START_TEST(test_ip_equal)
114 ip2.ip6.uint32[2] = htonl(0xFFFF); 114 ip2.ip6.uint32[2] = htonl(0xFFFF);
115 ip2.ip6.uint32[3] = htonl(0x7F000001); 115 ip2.ip6.uint32[3] = htonl(0x7F000001);
116 116
117 ck_assert_msg(IN6_IS_ADDR_V4MAPPED(&ip2.ip6.in6_addr) != 0, 117 ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip6) != 0,
118 "IN6_IS_ADDR_V4MAPPED(::ffff:127.0.0.1): expected != 0, got 0."); 118 "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0.");
119 119
120 res = ip_equal(&ip1, &ip2); 120 res = ip_equal(&ip1, &ip2);
121 ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::ffff:127.0.0.1} ): expected result != 0, got 0."); 121 ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::ffff:127.0.0.1} ): expected result != 0, got 0.");
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c
index 44ea9c7d..05264927 100644
--- a/auto_tests/onion_test.c
+++ b/auto_tests/onion_test.c
@@ -1,3 +1,5 @@
1#define _XOPEN_SOURCE 600
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c
index 9d36ff2d..448160c0 100644
--- a/auto_tests/save_friend_test.c
+++ b/auto_tests/save_friend_test.c
@@ -1,7 +1,10 @@
1/* Auto Tests: Save and load friends. 1/* Auto Tests: Save and load friends.
2 */ 2 */
3 3
4#define _XOPEN_SOURCE 600
5
4#include "helpers.h" 6#include "helpers.h"
7#include "../toxcore/tox.h"
5 8
6#include <assert.h> 9#include <assert.h>
7#include <stdio.h> 10#include <stdio.h>
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c
index 197c6e47..48f5671c 100644
--- a/auto_tests/tox_many_tcp_test.c
+++ b/auto_tests/tox_many_tcp_test.c
@@ -1,6 +1,8 @@
1/* Auto Tests: Many TCP. 1/* Auto Tests: Many TCP.
2 */ 2 */
3 3
4#define _XOPEN_SOURCE 600
5
4#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
5#include "config.h" 7#include "config.h"
6#endif 8#endif
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c
index 0c4c8c7d..b44bbb0c 100644
--- a/auto_tests/tox_many_test.c
+++ b/auto_tests/tox_many_test.c
@@ -1,6 +1,8 @@
1/* Auto Tests: Many clients. 1/* Auto Tests: Many clients.
2 */ 2 */
3 3
4#define _XOPEN_SOURCE 600
5
4#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
5#include "config.h" 7#include "config.h"
6#endif 8#endif
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index dfd1d80a..ab2202d1 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -10,6 +10,8 @@
10 * 10 *
11 */ 11 */
12 12
13#define _XOPEN_SOURCE 600
14
13#ifdef HAVE_CONFIG_H 15#ifdef HAVE_CONFIG_H
14#include "config.h" 16#include "config.h"
15#endif 17#endif
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 767fca87..79f552de 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -1,3 +1,5 @@
1#define _XOPEN_SOURCE 600
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index b33b93c8..1a10db44 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -1,3 +1,5 @@
1#define _XOPEN_SOURCE 600
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index e056de41..fa71d920 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -22,6 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 600
26
25#ifdef HAVE_CONFIG_H 27#ifdef HAVE_CONFIG_H
26#include "config.h" 28#include "config.h"
27#endif 29#endif
diff --git a/other/bootstrap_daemon/src/log.c b/other/bootstrap_daemon/src/log.c
index 7632d739..ae418f93 100644
--- a/other/bootstrap_daemon/src/log.c
+++ b/other/bootstrap_daemon/src/log.c
@@ -26,8 +26,8 @@
26 26
27#include "global.h" 27#include "global.h"
28 28
29#include <assert.h>
29#include <syslog.h> 30#include <syslog.h>
30
31#include <stdarg.h> 31#include <stdarg.h>
32#include <stdio.h> 32#include <stdio.h>
33 33
@@ -82,7 +82,22 @@ static int level_syslog(LOG_LEVEL level)
82 82
83static void log_syslog(LOG_LEVEL level, const char *format, va_list args) 83static void log_syslog(LOG_LEVEL level, const char *format, va_list args)
84{ 84{
85 vsyslog(level_syslog(level), format, args); 85 va_list args2;
86
87 va_copy(args2, args);
88 int size = vsnprintf(NULL, 0, format, args2);
89 va_end(args2);
90
91 assert(size >= 0);
92
93 if (size < 0) {
94 return;
95 }
96
97 char buf[size + 1];
98 vsnprintf(buf, size + 1, format, args);
99
100 syslog(level_syslog(level), "%s", buf);
86} 101}
87 102
88static FILE *level_stdout(LOG_LEVEL level) 103static FILE *level_stdout(LOG_LEVEL level)
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c
index 4495f88e..a0504eee 100644
--- a/other/bootstrap_daemon/src/tox-bootstrapd.c
+++ b/other/bootstrap_daemon/src/tox-bootstrapd.c
@@ -22,6 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 600
26
25// system provided 27// system provided
26#include <sys/stat.h> 28#include <sys/stat.h>
27#include <unistd.h> 29#include <unistd.h>
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index c994f543..6d20d550 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -27,6 +27,8 @@
27 * 27 *
28 */ 28 */
29 29
30#define _XOPEN_SOURCE 600
31
30#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
31#include "config.h" 33#include "config.h"
32#endif 34#endif
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index 4fd81649..695c50ae 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -37,6 +37,8 @@
37 * 37 *
38 */ 38 */
39 39
40#define _XOPEN_SOURCE 600
41
40#ifdef HAVE_CONFIG_H 42#ifdef HAVE_CONFIG_H
41#include "config.h" 43#include "config.h"
42#endif 44#endif
diff --git a/testing/av_test.c b/testing/av_test.c
index 7418a15a..aeb661be 100644
--- a/testing/av_test.c
+++ b/testing/av_test.c
@@ -22,6 +22,8 @@
22 * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio 22 * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 600
26
25#ifdef __cplusplus 27#ifdef __cplusplus
26extern "C" { 28extern "C" {
27#endif 29#endif
diff --git a/testing/irc_syncbot.c b/testing/irc_syncbot.c
index affc0296..b63b6151 100644
--- a/testing/irc_syncbot.c
+++ b/testing/irc_syncbot.c
@@ -1,3 +1,4 @@
1#define _XOPEN_SOURCE 600
1 2
2#include <stdint.h> 3#include <stdint.h>
3#include <stdio.h> 4#include <stdio.h>
@@ -34,8 +35,8 @@ static uint16_t port = 6667;
34 35
35static int sock; 36static int sock;
36 37
37#define SERVER_CONNECT "NICK "IRC_NAME"\nUSER "IRC_NAME" 8 * :"IRC_NAME"\n" 38#define SERVER_CONNECT "NICK " IRC_NAME "\nUSER " IRC_NAME " 8 * :" IRC_NAME "\n"
38#define CHANNEL_JOIN "JOIN "IRC_CHANNEL"\n" 39#define CHANNEL_JOIN "JOIN " IRC_CHANNEL "\n"
39 40
40/* In toxcore/network.c */ 41/* In toxcore/network.c */
41uint64_t current_time_monotonic(void); 42uint64_t current_time_monotonic(void);
@@ -131,8 +132,8 @@ static void copy_groupmessage(Tox *tox, uint32_t groupnumber, uint32_t friendgro
131 uint8_t sendbuf[2048]; 132 uint8_t sendbuf[2048];
132 uint16_t send_len = 0; 133 uint16_t send_len = 0;
133 134
134 memcpy(sendbuf, "PRIVMSG "IRC_CHANNEL" :", sizeof("PRIVMSG "IRC_CHANNEL" :")); 135 memcpy(sendbuf, "PRIVMSG " IRC_CHANNEL " :", sizeof("PRIVMSG " IRC_CHANNEL " :"));
135 send_len += sizeof("PRIVMSG "IRC_CHANNEL" :") - 1; 136 send_len += sizeof("PRIVMSG " IRC_CHANNEL " :") - 1;
136 memcpy(sendbuf + send_len, name, namelen); 137 memcpy(sendbuf + send_len, name, namelen);
137 send_len += namelen; 138 send_len += namelen;
138 sendbuf[send_len] = ':'; 139 sendbuf[send_len] = ':';
diff --git a/testing/misc_tools.c b/testing/misc_tools.c
index c1292ed8..30c813ca 100644
--- a/testing/misc_tools.c
+++ b/testing/misc_tools.c
@@ -29,6 +29,7 @@
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32#include <strings.h>
32 33
33#ifdef TOX_DEBUG 34#ifdef TOX_DEBUG
34#include <assert.h> 35#include <assert.h>
diff --git a/testing/tox_shell.c b/testing/tox_shell.c
index 18aad9c7..d5de3e67 100644
--- a/testing/tox_shell.c
+++ b/testing/tox_shell.c
@@ -26,6 +26,8 @@
26 * 26 *
27 */ 27 */
28 28
29#define _XOPEN_SOURCE 600
30
29#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
30#include "config.h" 32#include "config.h"
31#endif 33#endif
diff --git a/testing/tox_sync.c b/testing/tox_sync.c
index 0c91abfd..6ac3dcf0 100644
--- a/testing/tox_sync.c
+++ b/testing/tox_sync.c
@@ -28,6 +28,8 @@
28 * 28 *
29 */ 29 */
30 30
31#define _XOPEN_SOURCE 600
32
31#ifdef HAVE_CONFIG_H 33#ifdef HAVE_CONFIG_H
32#include "config.h" 34#include "config.h"
33#endif 35#endif
@@ -42,6 +44,7 @@
42#include <dirent.h> 44#include <dirent.h>
43#include <netinet/in.h> 45#include <netinet/in.h>
44#include <stdio.h> 46#include <stdio.h>
47#include <sys/stat.h>
45 48
46#define NUM_FILE_SENDERS 256 49#define NUM_FILE_SENDERS 256
47typedef struct { 50typedef struct {
@@ -297,6 +300,7 @@ int main(int argc, char *argv[])
297 memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4])); 300 memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4]));
298 DIR *d; 301 DIR *d;
299 struct dirent *dir; 302 struct dirent *dir;
303 struct stat statbuf;
300 uint8_t notconnected = 1; 304 uint8_t notconnected = 1;
301 305
302 while (1) { 306 while (1) {
@@ -310,7 +314,12 @@ int main(int argc, char *argv[])
310 314
311 if (d) { 315 if (d) {
312 while ((dir = readdir(d)) != NULL) { 316 while ((dir = readdir(d)) != NULL) {
313 if (dir->d_type == DT_REG) { 317 char filepath[strlen(path) + strlen(dir->d_name) + 1];
318 memcpy(filepath, path, strlen(path));
319 memcpy(filepath + strlen(path), dir->d_name, strlen(dir->d_name) + 1);
320 stat(filepath, &statbuf);
321
322 if (S_ISREG(statbuf.st_mode)) {
314 char fullpath[1024]; 323 char fullpath[1024];
315 324
316 if (path[strlen(path) - 1] == '/') { 325 if (path[strlen(path) - 1] == '/') {
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c
index 0e2d0085..d9ace28a 100644
--- a/toxcore/TCP_server.c
+++ b/toxcore/TCP_server.c
@@ -619,7 +619,7 @@ static int send_routing_response(TCP_Secure_Connection *con, uint8_t rpid, const
619 */ 619 */
620static int send_connect_notification(TCP_Secure_Connection *con, uint8_t id) 620static int send_connect_notification(TCP_Secure_Connection *con, uint8_t id)
621{ 621{
622 uint8_t data[2] = {TCP_PACKET_CONNECTION_NOTIFICATION, id + NUM_RESERVED_PORTS}; 622 uint8_t data[2] = {TCP_PACKET_CONNECTION_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
623 return write_packet_TCP_secure_connection(con, data, sizeof(data), 1); 623 return write_packet_TCP_secure_connection(con, data, sizeof(data), 1);
624} 624}
625 625
@@ -629,7 +629,7 @@ static int send_connect_notification(TCP_Secure_Connection *con, uint8_t id)
629 */ 629 */
630static int send_disconnect_notification(TCP_Secure_Connection *con, uint8_t id) 630static int send_disconnect_notification(TCP_Secure_Connection *con, uint8_t id)
631{ 631{
632 uint8_t data[2] = {TCP_PACKET_DISCONNECT_NOTIFICATION, id + NUM_RESERVED_PORTS}; 632 uint8_t data[2] = {TCP_PACKET_DISCONNECT_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
633 return write_packet_TCP_secure_connection(con, data, sizeof(data), 1); 633 return write_packet_TCP_secure_connection(con, data, sizeof(data), 1);
634} 634}
635 635
diff --git a/toxcore/network.c b/toxcore/network.c
index 31e8fd8b..250a304b 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define _XOPEN_SOURCE 600
25
24#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_WINXP 26#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_WINXP
25#define _WIN32_WINNT 0x501 27#define _WIN32_WINNT 0x501
26#endif 28#endif
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 37298ce2..3276d2d5 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define _XOPEN_SOURCE 600
25
24#ifdef HAVE_CONFIG_H 26#ifdef HAVE_CONFIG_H
25#include "config.h" 27#include "config.h"
26#endif 28#endif
diff --git a/toxcore/util.c b/toxcore/util.c
index 7a390ea9..1d2a85dc 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -22,6 +22,8 @@
22 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 22 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 600
26
25#ifdef HAVE_CONFIG_H 27#ifdef HAVE_CONFIG_H
26#include "config.h" 28#include "config.h"
27#endif 29#endif