Skip to content

Commit 890633a

Browse files
quicktest: Remove more unguarded List.hd calls
Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
1 parent a7c863f commit 890633a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ocaml/xapi/quicktest.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,13 @@ let setup_export_test_vm session_id =
327327
| sr, None -> debug test (Printf.sprintf "SR %s has no minimum disk size!" sr)
328328
) (List.combine sr_names smallest);
329329
let minimum = List.fold_left min (1L ** gib) (List.map (fun x -> Opt.default (1L ** gib) x) smallest) in
330-
let possible_srs = List.filter (fun (sr, size) -> size = Some minimum) (List.combine all_srs smallest) in
331-
if List.length possible_srs = 0 then begin
332-
failed test "Failed to find an SR which can create a VDI";
333-
failwith "setup_export_test_vm";
334-
end;
335-
let sr = fst (List.hd possible_srs) in
330+
let sr =
331+
match List.filter (fun (_, size) -> size = Some minimum) (List.combine all_srs smallest) with
332+
| (sr, _)::_ -> sr
333+
| [] ->
334+
failed test "Failed to find an SR which can create a VDI";
335+
failwith "setup_export_test_vm";
336+
in
336337
debug test (Printf.sprintf "Using a disk size of: %Ld on SR: %s" minimum (Quicktest_storage.name_of_sr session_id sr));
337338
let vdi = Client.VDI.create !rpc session_id "small"
338339
"description" sr 4194304L `user false false [] [] [] [] in

0 commit comments

Comments
 (0)