Closed
Description
Here's a bug generated by a simple copy-paste mistake:
fn init_flash_access(freq: u32) {
let num_clocks: u32 = if freq > 100_000_000 { 6 } else
if freq > 80_000_000 { 5 } else
if freq > 60_000_000 { 4 } else
if freq > 40_000_000 { 3 } else
if freq > 40_000_000 { 2 } else
{ 1 };
let val = (num_clocks - 1) << 12;
reg::FLASHCFG.set_value(val);
}
This function will never return 2, as 40_000_000
in the last line should actually be 20_000_000
. Is there any way rust could warn me about that or any other applicable pattern to do it?