Skip to content

Commit

Permalink
Remove usize_from_u32.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed May 23, 2024
1 parent e7b24ba commit 8238c00
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
10 changes: 2 additions & 8 deletions src/aead/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use super::{nonce::Nonce, quic::Sample};
use crate::{
bits::BitLength,
c, constant_time, cpu, error,
polyfill::{self, slice},
};
use crate::{bits::BitLength, c, constant_time, cpu, error, polyfill::slice};
use core::{num::NonZeroUsize, ops::RangeFrom};

#[derive(Clone)]
Expand Down Expand Up @@ -143,9 +139,7 @@ unsafe fn ctr32_encrypt_blocks(
}
};

#[allow(clippy::cast_possible_truncation)]
let blocks_u32 = blocks.get() as u32;
assert_eq!(blocks.get(), polyfill::usize_from_u32(blocks_u32));
let blocks_u32: u32 = blocks.get().try_into().unwrap();

let input = input.as_ptr();
let output: *mut [u8; BLOCK_LEN] = in_out.as_mut_ptr().cast();
Expand Down
5 changes: 0 additions & 5 deletions src/polyfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ pub const fn u64_from_usize(x: usize) -> u64 {
x as u64
}

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
pub fn usize_from_u32(x: u32) -> usize {
x as usize
}

#[cfg(all(target_arch = "aarch64", target_pointer_width = "64"))]
#[allow(clippy::cast_possible_truncation)]
pub fn usize_from_u64(x: u64) -> usize {
Expand Down

0 comments on commit 8238c00

Please sign in to comment.