mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Use explicit 0 instead of PACKET_ID_PADDING
.
Calling it a packet ID is a lie, and we'd rather "memzero" than memset with some named value that happens to be 0.
This commit is contained in:
parent
6370d0f15d
commit
a7258e40cf
|
@ -1139,7 +1139,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3
|
||||||
VLA(uint8_t, packet, sizeof(uint32_t) + sizeof(uint32_t) + padding_length + length);
|
VLA(uint8_t, packet, sizeof(uint32_t) + sizeof(uint32_t) + padding_length + length);
|
||||||
memcpy(packet, &buffer_start, sizeof(uint32_t));
|
memcpy(packet, &buffer_start, sizeof(uint32_t));
|
||||||
memcpy(packet + sizeof(uint32_t), &num, sizeof(uint32_t));
|
memcpy(packet + sizeof(uint32_t), &num, sizeof(uint32_t));
|
||||||
memset(packet + (sizeof(uint32_t) * 2), PACKET_ID_PADDING, padding_length);
|
memset(packet + (sizeof(uint32_t) * 2), 0, padding_length);
|
||||||
memcpy(packet + (sizeof(uint32_t) * 2) + padding_length, data, length);
|
memcpy(packet + (sizeof(uint32_t) * 2) + padding_length, data, length);
|
||||||
|
|
||||||
return send_data_packet(c, crypt_connection_id, packet, SIZEOF_VLA(packet));
|
return send_data_packet(c, crypt_connection_id, packet, SIZEOF_VLA(packet));
|
||||||
|
@ -1589,7 +1589,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
||||||
const uint8_t *real_data = data + (sizeof(uint32_t) * 2);
|
const uint8_t *real_data = data + (sizeof(uint32_t) * 2);
|
||||||
uint16_t real_length = len - (sizeof(uint32_t) * 2);
|
uint16_t real_length = len - (sizeof(uint32_t) * 2);
|
||||||
|
|
||||||
while (real_data[0] == PACKET_ID_PADDING) { /* Remove Padding */
|
while (real_data[0] == 0) { /* Remove Padding */
|
||||||
++real_data;
|
++real_data;
|
||||||
--real_length;
|
--real_length;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
/*** Messages. */
|
/*** Messages. */
|
||||||
|
|
||||||
typedef enum Packet_Id {
|
typedef enum Packet_Id {
|
||||||
PACKET_ID_PADDING = 0, // Denotes padding
|
|
||||||
PACKET_ID_REQUEST = 1, // Used to request unreceived packets
|
PACKET_ID_REQUEST = 1, // Used to request unreceived packets
|
||||||
PACKET_ID_KILL = 2, // Used to kill connection
|
PACKET_ID_KILL = 2, // Used to kill connection
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user