Fixed warnings.

This commit is contained in:
irungentoo 2013-07-22 07:26:25 -04:00
parent 11891e2475
commit 635e921c14
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/* DHT test /* DHT test
* A file with a main that runs our DHT for testing. * A file with a main that runs our DHT for testing.
* *
* Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/ DHT_test.c * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/{cpucycles.o,libnacl.a,randombytes.o} DHT_test.c
* *
* Command line arguments are the ip, port and public key of a node. * Command line arguments are the ip, port and public key of a node.
* EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

View File

@ -229,7 +229,11 @@ int main(int argc, char *argv[])
int size = ftell(data_file); int size = ftell(data_file);
fseek(data_file, 0, SEEK_SET); fseek(data_file, 0, SEEK_SET);
uint8_t data[size]; uint8_t data[size];
fread(data, sizeof(uint8_t), size, data_file); if(fread(data, sizeof(uint8_t), size, data_file) != size)
{
printf("Error reading file\n");
exit(0);
}
Messenger_load(data, size); Messenger_load(data, size);
} else { } else {
//else save new keys //else save new keys
@ -237,7 +241,11 @@ int main(int argc, char *argv[])
uint8_t data[size]; uint8_t data[size];
Messenger_save(data); Messenger_save(data);
data_file = fopen("data","w"); data_file = fopen("data","w");
fwrite(data, sizeof(uint8_t), size, data_file); if(fwrite(data, sizeof(uint8_t), size, data_file) != size)
{
printf("Error writing file\n");
exit(0);
}
} }
fclose(data_file); fclose(data_file);
m_callback_friendrequest(print_request); m_callback_friendrequest(print_request);