Skip to content

Commit a7258e4

Browse files
committed
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.
1 parent 6370d0f commit a7258e4

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

toxcore/net_crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3
11391139
VLA(uint8_t, packet, sizeof(uint32_t) + sizeof(uint32_t) + padding_length + length);
11401140
memcpy(packet, &buffer_start, sizeof(uint32_t));
11411141
memcpy(packet + sizeof(uint32_t), &num, sizeof(uint32_t));
1142-
memset(packet + (sizeof(uint32_t) * 2), PACKET_ID_PADDING, padding_length);
1142+
memset(packet + (sizeof(uint32_t) * 2), 0, padding_length);
11431143
memcpy(packet + (sizeof(uint32_t) * 2) + padding_length, data, length);
11441144

11451145
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
15891589
const uint8_t *real_data = data + (sizeof(uint32_t) * 2);
15901590
uint16_t real_length = len - (sizeof(uint32_t) * 2);
15911591

1592-
while (real_data[0] == PACKET_ID_PADDING) { /* Remove Padding */
1592+
while (real_data[0] == 0) { /* Remove Padding */
15931593
++real_data;
15941594
--real_length;
15951595

toxcore/net_crypto.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
/*** Messages. */
4545

4646
typedef enum Packet_Id {
47-
PACKET_ID_PADDING = 0, // Denotes padding
4847
PACKET_ID_REQUEST = 1, // Used to request unreceived packets
4948
PACKET_ID_KILL = 2, // Used to kill connection
5049

0 commit comments

Comments
 (0)