Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Don't use memcpy where assignment can be used. #1864

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
973f8254b9f8c50cbf0df93fb609d83bfeaeffdcbe7b836d6e0f701bdabf493f /usr/local/bin/tox-bootstrapd
c2d45e89278e21f452cce2589299648bb94c38d75b0e974fb4f1c012182543af /usr/local/bin/tox-bootstrapd
4 changes: 1 addition & 3 deletions toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,7 @@ int dht_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count)
--dht->num_friends;

if (dht->num_friends != friend_num) {
memcpy(&dht->friends_list[friend_num],
&dht->friends_list[dht->num_friends],
sizeof(DHT_Friend));
dht->friends_list[friend_num] = dht->friends_list[dht->num_friends];
}

if (dht->num_friends == 0) {
Expand Down
2 changes: 1 addition & 1 deletion toxcore/TCP_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void wipe_secure_connection(TCP_Secure_Connection *con)

static void move_secure_connection(TCP_Secure_Connection *con_new, TCP_Secure_Connection *con_old)
{
memcpy(con_new, con_old, sizeof(TCP_Secure_Connection));
*con_new = *con_old;
crypto_memzero(con_old, sizeof(TCP_Secure_Connection));
}

Expand Down
6 changes: 3 additions & 3 deletions toxcore/net_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ static int add_data_to_buffer(const Logger *log, Packets_Array *array, uint32_t
return -1;
}

memcpy(new_d, data, sizeof(Packet_Data));
*new_d = *data;
array->buffer[num] = new_d;

if (number - array->buffer_start >= num_packets_array(array)) {
Expand Down Expand Up @@ -808,7 +808,7 @@ static int64_t add_data_end_of_buffer(const Logger *log, Packets_Array *array, c
return -1;
}

memcpy(new_d, data, sizeof(Packet_Data));
*new_d = *data;
uint32_t id = array->buffer_end;
array->buffer[id % CRYPTO_PACKET_BUFFER_SIZE] = new_d;
++array->buffer_end;
Expand All @@ -832,7 +832,7 @@ static int64_t read_data_beg_buffer(const Logger *log, Packets_Array *array, Pac
return -1;
}

memcpy(data, array->buffer[num], sizeof(Packet_Data));
*data = *array->buffer[num];
uint32_t id = array->buffer_start;
++array->buffer_start;
free(array->buffer[num]);
Expand Down
2 changes: 1 addition & 1 deletion toxcore/onion_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_pa
}

++onion_paths->last_path_used_times[pathnum];
memcpy(path, &onion_paths->paths[pathnum], sizeof(Onion_Path));
*path = onion_paths->paths[pathnum];
return 0;
}

Expand Down