Fixed warnings and moved hex_string_to_bin to testing/

This commit is contained in:
irungentoo 2013-08-30 08:16:34 -04:00
parent 7441a234b7
commit 8f0bef5f20
11 changed files with 13 additions and 18 deletions

View File

@ -29,7 +29,7 @@
#include "../toxcore/DHT.h"
#include "../toxcore/friend_requests.h"
#include "../toxcore/misc_tools.h"
#include "../testing/misc_tools.c"
/* Sleep function (x = milliseconds) */
#ifdef WIN32

View File

@ -2,8 +2,7 @@ noinst_PROGRAMS += DHT_bootstrap
DHT_bootstrap_SOURCES = $(top_srcdir)/other/DHT_bootstrap.c \
$(top_srcdir)/toxcore/DHT.h \
$(top_srcdir)/toxcore/friend_requests.h \
$(top_srcdir)/toxcore/misc_tools.h
$(top_srcdir)/toxcore/friend_requests.h
DHT_bootstrap_CFLAGS = -I$(top_srcdir)/other \
$(LIBSODIUM_CFLAGS)

View File

@ -30,7 +30,7 @@
//#include "../core/network.h"
#include "../toxcore/DHT.h"
#include "../toxcore/friend_requests.h"
#include "../toxcore/misc_tools.h"
#include "misc_tools.c"
#include <string.h>

View File

@ -38,7 +38,7 @@
*/
#include "../toxcore/Messenger.h"
#include "../toxcore/misc_tools.h"
#include "misc_tools.c"
#ifdef WIN32

View File

@ -21,8 +21,6 @@
*
*/
#include "misc_tools.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

View File

@ -38,7 +38,7 @@
#include "nTox.h"
#include "../toxcore/misc_tools.h"
#include "misc_tools.c"
#include <stdio.h>
#include <time.h>

View File

@ -675,7 +675,7 @@ IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id)
{
uint32_t i, j;
uint64_t temp_time = unix_time();
IP_Port empty = { .ip = {0}, .port = 0, .padding = 0 };
IP_Port empty = { .ip = {{0}}, .port = 0, .padding = 0 };
for (i = 0; i < dht->num_friends; ++i) {
/* Equal */
@ -1040,7 +1040,7 @@ static void punch_holes(DHT *dht, IP ip, uint16_t *port_list, uint16_t numports,
for (i = dht->friends_list[friend_num].punching_index; i != top; i++) {
/* TODO: improve port guessing algorithm */
uint16_t port = port_list[(i / 2) % numports] + (i / (2 * numports)) * ((i % 2) ? -1 : 1);
IP_Port pinging = {ip, htons(port)};
IP_Port pinging = {.ip = ip, .port = htons(port)};
send_ping_request(dht->ping, dht->c, pinging, dht->friends_list[friend_num].client_id);
}

View File

@ -117,7 +117,8 @@ static int LAN_ip(IP ip)
if (ip.uint8[0] == 192 && ip.uint8[1] == 168) /* 192.168.0.0 to 192.168.255.255 range. */
return 0;
if (ip.uint8[0] == 169 && ip.uint8[1] == 254 && ip.uint8[2] != 0 && ip.uint8[2] != 255)/* 169.254.1.0 to 169.254.254.255 range. */
if (ip.uint8[0] == 169 && ip.uint8[1] == 254 && ip.uint8[2] != 0
&& ip.uint8[2] != 255)/* 169.254.1.0 to 169.254.254.255 range. */
return 0;
return -1;
@ -143,7 +144,7 @@ int send_LANdiscovery(uint16_t port, Net_Crypto *c)
uint8_t data[crypto_box_PUBLICKEYBYTES + 1];
data[0] = NET_PACKET_LAN_DISCOVERY;
memcpy(data + 1, c->self_public_key, crypto_box_PUBLICKEYBYTES);
IP_Port ip_port = {broadcast_ip(), port};
IP_Port ip_port = {.ip = broadcast_ip(), .port = port};
return sendpacket(c->lossless_udp->net->sock, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES);
}

View File

@ -39,7 +39,7 @@
int getconnection_id(Lossless_UDP *ludp, IP_Port ip_port)
{
tox_array_for_each(&ludp->connections, Connection, tmp) {
if (tmp->ip_port.ip.i == ip_port.ip.i &&
if (tmp->ip_port.ip.uint32 == ip_port.ip.uint32 &&
tmp->ip_port.port == ip_port.port &&
tmp->status > 0) {
return tmp_i;
@ -261,7 +261,7 @@ IP_Port connection_ip(Lossless_UDP *ludp, int connection_id)
if (connection_id >= 0 && connection_id < ludp->connections.len)
return tox_array_get(&ludp->connections, connection_id, Connection).ip_port;
IP_Port zero = { .ip = {0}, .port = 0, .padding = 0 };
IP_Port zero = { .ip = {{0}}, .port = 0, .padding = 0 };
return zero;
}

View File

@ -25,8 +25,7 @@ libtoxcore_la_SOURCES = $(top_srcdir)/toxcore/DHT.h \
$(top_srcdir)/toxcore/tox.c \
$(top_srcdir)/toxcore/util.h \
$(top_srcdir)/toxcore/util.c \
$(top_srcdir)/toxcore/misc_tools.h \
$(top_srcdir)/toxcore/misc_tools.c
$(top_srcdir)/toxcore/misc_tools.h
libtoxcore_la_CFLAGS = -I$(top_srcdir) \
-I$(top_srcdir)/toxcore \

View File

@ -28,8 +28,6 @@
#include <stdint.h>
#include <string.h> /* for memcpy() */
unsigned char *hex_string_to_bin(char hex_string[]);
/*********************Debugging Macros********************
* wiki.tox.im/index.php/Internal_functions_and_data_structures#Debugging
*********************************************************/