Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/cmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();
let mut results: Vec<StageResult> = Vec::new();

if args.server_address.is_some() {
if let Some(server_address) = args.server_address {
let (resp_tx, resp_rx) = channel();

let _resp_handler = thread::spawn(move || loop {
Expand Down Expand Up @@ -306,7 +306,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
});

let ip = IpAddr::from_str(&args.server_address.unwrap()).expect("Invalid IP address");
let ip = IpAddr::from_str(&server_address).expect("Invalid IP address");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a good refactoring to avoid unwrap(). A similar issue exists on line 312 with args.bind_address.unwrap(), which will panic if the --bind-address argument is not provided. Since rdma_resolve_addr can accept a null source address (which corresponds to None for the src_addr Option), you could handle this more robustly. A possible approach is to create an Option<SocketAddr> for the client address and pass that to resolve_addr, avoiding the panic and allowing the system to select a source address if one isn't specified.

let server_addr = SocketAddr::from((ip, args.port));

let ip = IpAddr::from_str(&args.bind_address.unwrap()).expect("Invalid IP address");
Expand Down
Loading