[Client] Fix initialisation of packet_size

+Fix print_usage()
This commit is contained in:
Matteo Cypriani 2010-10-25 13:06:55 +02:00
parent 56c831ffab
commit c31d753e00
1 changed files with 6 additions and 7 deletions

View File

@ -284,7 +284,6 @@ inline void create_socket()
void make_packet()
{
int offset ; // Index used to create the packet
int size ; // Packet size
struct timeval request_time ;
gettimeofday(&request_time, NULL) ;
@ -294,9 +293,9 @@ void make_packet()
printf("Calibration time: %llu\n", timeval_to_ms(request_time)) ;
offset = 0 ;
size =
packet_size =
sizeof(char) * 2 + sizeof(struct timeval) + sizeof(float) * 3 ;
packet = malloc(size) ;
packet = malloc(packet_size) ;
packet[offset++] = PACKET_TYPE_CALIBRATION ; // Packet type
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
@ -316,8 +315,8 @@ void make_packet()
else // Standard packet
{
printf("Request time: %llu\n", timeval_to_ms(request_time)) ;
size = sizeof(char) + sizeof(struct timeval) ;
packet = malloc(size) ;
packet_size = sizeof(char) + sizeof(struct timeval) ;
packet = malloc(packet_size) ;
packet[0] = PACKET_TYPE_NORMAL ; // Packet type
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
}
@ -356,8 +355,8 @@ void print_usage()
"\t%s -d dest_ip [-p dest_port] [-i iface] [-t delay]"
" [-n nb_packets] [-l [port]]\n"
"Calibration request:\n"
"\t%s -d dest_ip [-i iface] [-t delay] [-n nb_packets]"
" direction x y z\n"
"\t%s -d dest_ip [-p dest_port] [-i iface] [-t delay]"
" [-n nb_packets] direction x y z\n"
"\n"
"Options:\n"
"\t-h\t\tPrint this help.\n"