[Client] make_packet(): use memset() for the type
Use memset() instead of a direct allocation to set the packet type, to avoid implicit cast (even though it seems useless here).
This commit is contained in:
parent
2771f8573b
commit
fe3c509831
|
@ -296,10 +296,11 @@ void make_packet()
|
||||||
|
|
||||||
offset = 0 ;
|
offset = 0 ;
|
||||||
packet_size =
|
packet_size =
|
||||||
sizeof(char) * 2 + sizeof(TIMESTAMP) + sizeof(float) * 3 ;
|
sizeof(uint8_t) * 2 + sizeof(TIMESTAMP) + sizeof(float) * 3 ;
|
||||||
packet = malloc(packet_size) ;
|
packet = malloc(packet_size) ;
|
||||||
|
|
||||||
packet[offset++] = PACKET_TYPE_CALIBRATION ; // Packet type
|
memset(&packet[offset], PACKET_TYPE_CALIBRATION, 1) ; // Packet type
|
||||||
|
++offset ;
|
||||||
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
|
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
|
||||||
offset += sizeof(request_time) ;
|
offset += sizeof(request_time) ;
|
||||||
packet[offset++] = options.direction ; // Direction
|
packet[offset++] = options.direction ; // Direction
|
||||||
|
@ -318,9 +319,9 @@ void make_packet()
|
||||||
{
|
{
|
||||||
printf("Request time: %"PRIu64"\n",
|
printf("Request time: %"PRIu64"\n",
|
||||||
timestamp_to_ms(request_time)) ;
|
timestamp_to_ms(request_time)) ;
|
||||||
packet_size = sizeof(char) + sizeof(TIMESTAMP) ;
|
packet_size = sizeof(uint8_t) + sizeof(TIMESTAMP) ;
|
||||||
packet = malloc(packet_size) ;
|
packet = malloc(packet_size) ;
|
||||||
packet[0] = PACKET_TYPE_NORMAL ; // Packet type
|
memset(&packet[0], PACKET_TYPE_NORMAL, 1) ; // Packet type
|
||||||
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue