Skip to content

Commit e65a0e9

Browse files
committed
Changed prefix conversion to use saturating sub
1 parent 7b8da9d commit e65a0e9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bgpsim/src/types/prefix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ impl From<i32> for SimplePrefix {
653653
impl From<Ipv4Addr> for SimplePrefix {
654654
fn from(value: Ipv4Addr) -> Self {
655655
let num: u32 = value.into();
656-
SimplePrefix((num - (100 << 24)) >> 8)
656+
// WARNING: Do not merge this before talking to Tibor, this is a hack
657+
SimplePrefix(num.saturating_sub(100u32 << 24) >> 8)
657658
}
658659
}
659660

0 commit comments

Comments
 (0)