Skip to content

Commit

Permalink
Add a comment about our usage of List.hd (which can fail) and String.…
Browse files Browse the repository at this point in the history
…split_on_char
  • Loading branch information
dinosaure committed May 22, 2024
1 parent 86a65a6 commit 635f47e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dao.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ let vifs client domid =
let get_client_ip () =
let* str = Xen_os.Xs.read handle (Fmt.str "%s/%d/ip" path device_id) in
let client_ip = List.hd (String.split_on_char ' ' str) in
(* XXX(dinosaure): it's safe to use [List.hd] here,
[String.split_on_char] can not return an empty list. *)
Lwt.return_some (vif, Ipaddr.V4.of_string_exn client_ip)
in
Lwt.catch get_client_ip @@ function
Expand Down

0 comments on commit 635f47e

Please sign in to comment.