Skip to content

Commit

Permalink
Warn on unparseable env values
Browse files Browse the repository at this point in the history
  • Loading branch information
eightbitraptor committed Oct 18, 2024
1 parent c670308 commit 864bc90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gc/mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ pub extern "C" fn mmtk_builder_default() -> *mut MMTKBuilder {
const DEFAULT_HEAP_MIN: usize = 1 << 20;

let mut mmtk_heap_min = match std::env::var("MMTK_HEAP_MIN") {
Ok(mode) if (mode.parse::<usize>().is_ok()) => mode.parse::<usize>().unwrap(),
Ok(min) if (min.parse::<usize>().is_ok()) => min.parse::<usize>().unwrap(),
Ok(min) if (!min.parse::<usize>().is_ok()) => {
eprintln!("MMTK_HEAP_MIN value is incorrect ({}), Using default value.", min);
DEFAULT_HEAP_MIN
}
Ok(_) | Err(_) => DEFAULT_HEAP_MIN
};

let mut mmtk_heap_max = match std::env::var("MMTK_HEAP_MAX") {
Ok(mode) if (mode.parse::<usize>().is_ok()) => mode.parse::<usize>().unwrap(),
Ok(max) if (max.parse::<usize>().is_ok()) => max.parse::<usize>().unwrap(),
Ok(max) if (!max.parse::<usize>().is_ok()) => {
eprintln!("MMTK_HEAP_MAX value is incorrect ({}), Using default value.", max);
default_heap_max()
}
Ok(_) | Err(_) => default_heap_max()
};

Expand Down

0 comments on commit 864bc90

Please sign in to comment.