Add a comment about our usage of List.hd (which can fail) and String.split_on_char

This commit is contained in:
Calascibetta Romain 2024-05-22 11:47:10 +02:00 committed by Hannes Mehnert
parent ad1afe99ee
commit 3dc545681d

2
dao.ml
View File

@ -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