Skip to content

Commit 04da5f5

Browse files
committed
get rid of transmute from instructions/arithmetic/i256.rs
1 parent 612b14d commit 04da5f5

File tree

1 file changed

+3
-3
lines changed
  • substrate/frame/revive/src/vm/evm/instructions/arithmetic

1 file changed

+3
-3
lines changed

substrate/frame/revive/src/vm/evm/instructions/arithmetic/i256.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub enum Sign {
2727
Minus = -1,
2828
/// Zero value sign
2929
Zero = 0,
30-
#[allow(dead_code)] // "constructed" with `mem::transmute` in `i256_sign` below
3130
/// Positive value sign
3231
Plus = 1,
3332
}
@@ -43,9 +42,10 @@ const FLIPH_BITMASK_U64: u64 = 0x7FFF_FFFF_FFFF_FFFF;
4342
pub fn i256_sign(val: &U256) -> Sign {
4443
if val.bit(255) {
4544
Sign::Minus
45+
} else if val.is_zero() {
46+
Sign::Zero
4647
} else {
47-
// SAFETY: false == 0 == Zero, true == 1 == Plus
48-
unsafe { core::mem::transmute::<bool, Sign>(!val.is_zero()) }
48+
Sign::Plus
4949
}
5050
}
5151

0 commit comments

Comments
 (0)