Skip to content

Commit

Permalink
unnecessary_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed Dec 13, 2023
1 parent 6947544 commit 470240c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 3 additions & 9 deletions src/c/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,7 @@ pub(crate) unsafe fn enet_peer_queue_incoming_command<S: Socket>(
((*packet).reference_count).wrapping_add(1);
(*peer).total_waiting_data = (*peer)
.total_waiting_data
.wrapping_add((*packet).data_length)
as usize
as usize;
.wrapping_add((*packet).data_length);
}
enet_list_insert(
(*current_command).next,
Expand Down Expand Up @@ -1439,9 +1437,7 @@ pub(crate) unsafe fn enet_peer_queue_incoming_command<S: Socket>(
((*packet).reference_count).wrapping_add(1);
(*peer).total_waiting_data = (*peer)
.total_waiting_data
.wrapping_add((*packet).data_length)
as usize
as usize;
.wrapping_add((*packet).data_length);
}
enet_list_insert(
(*current_command).next,
Expand Down Expand Up @@ -1684,9 +1680,7 @@ pub(crate) unsafe fn enet_peer_queue_incoming_command<S: Socket>(
((*packet).reference_count).wrapping_add(1);
(*peer).total_waiting_data = (*peer)
.total_waiting_data
.wrapping_add((*packet).data_length)
as usize
as usize;
.wrapping_add((*packet).data_length);
}
enet_list_insert(
(*current_command).next,
Expand Down
11 changes: 4 additions & 7 deletions src/c/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ unsafe fn enet_protocol_remove_sent_reliable_command<S: Socket>(
if was_sent != 0 {
(*peer).reliable_data_in_transit = (*peer)
.reliable_data_in_transit
.wrapping_sub((*outgoing_command).fragment_length as u32)
as u32 as u32;
.wrapping_sub((*outgoing_command).fragment_length as u32);
}
(*(*outgoing_command).packet).reference_count =
((*(*outgoing_command).packet).reference_count).wrapping_sub(1);
Expand Down Expand Up @@ -1687,8 +1686,7 @@ unsafe fn enet_protocol_receive_incoming_commands<S: Socket>(
(*host).received_data_length = received_length as usize;
(*host).total_received_data = (*host)
.total_received_data
.wrapping_add(received_length as u32) as u32
as u32;
.wrapping_add(received_length as u32);
(*host).total_received_packets = ((*host).total_received_packets).wrapping_add(1);
match enet_protocol_handle_incoming_commands(host, event) {
1 => return 1_i32,
Expand Down Expand Up @@ -2001,8 +1999,7 @@ unsafe fn enet_protocol_check_outgoing_commands<S: Socket>(
as u16;
(*peer).reliable_data_in_transit = (*peer)
.reliable_data_in_transit
.wrapping_add((*outgoing_command).fragment_length as u32)
as u32 as u32;
.wrapping_add((*outgoing_command).fragment_length as u32);
} else {
if !((*outgoing_command).packet).is_null()
&& (*outgoing_command).fragment_offset == 0_i32 as u32
Expand Down Expand Up @@ -2063,7 +2060,7 @@ unsafe fn enet_protocol_check_outgoing_commands<S: Socket>(
(*buffer).data_length = (*outgoing_command).fragment_length as usize;
(*host).packet_size = ((*host).packet_size as u64)
.wrapping_add((*outgoing_command).fragment_length as u64)
as usize as usize;
as usize;
} else if (*outgoing_command).command.header.command as i32
& ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE as i32
== 0
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
clippy::borrow_as_ptr,
clippy::items_after_statements,
clippy::single_match_else,
clippy::bool_to_int_with_if
clippy::bool_to_int_with_if,
clippy::unnecessary_cast
)]
// https://github.com/rust-lang/rust-clippy/issues/11382
#![allow(clippy::arc_with_non_send_sync)]
Expand Down

0 comments on commit 470240c

Please sign in to comment.