Skip to content

Commit eb20684

Browse files
author
Jorge Aparicio
committed
address second row of review
1 parent 1c22269 commit eb20684

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/div.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
77

88
// Special cases
99
if d == 0 {
10-
return 0; // ?!
10+
panic!("Division by zero");
1111
}
1212

1313
if n == 0 {
@@ -49,8 +49,7 @@ pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
4949
r -= d & s as u32;
5050
}
5151

52-
q = (q << 1) | carry;
53-
q
52+
(q << 1) | carry
5453
}
5554

5655
/// Returns `n / d` and sets `*rem = n % d`
@@ -105,13 +104,7 @@ pub extern "C" fn __udivmoddi4(n: u64, d: u64, rem: Option<&mut u64>) -> u64 {
105104
// ---
106105
// 0 0
107106

108-
// NOTE copied verbatim from compiler-rt. This probably lets the intrinsic decide how to
109-
// handle the division by zero (SIGFPE, 0, etc.). But this part shouldn't be reachable
110-
// from safe code.
111-
if let Some(rem) = rem {
112-
*rem = u64::from(n.high() % d.low());
113-
}
114-
return u64::from(n.high() / d.low());
107+
panic!("Division by zero");
115108
}
116109

117110
// d.high() != 0

0 commit comments

Comments
 (0)