Files
xen/tools/ocaml/test/xtl.ml
T
Christian Lindig f99941871a tools/ocaml: cleanup to reduce compiler warnings
This commit cleans up code to reduce compiler warnings:

* remove unused open statements (warning 33)
* remove unused 'rec' declarations (warnign 39)
* remove unused type declarations (warning 34)
* mark unused variables with an underscore (warning 27)
* mark unused value declarations with an underscore (warning 32)

This commit does not include changes to fix compiler warnings 52
(matching against strings in exceptions). These changes have no impact
on functionality.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2018-11-14 18:22:09 +00:00

40 lines
1.1 KiB
OCaml

open Printf
open Xentoollog
let stdio_vmessage min_level level errno ctx msg =
let level_str = level_to_string level
and errno_str = match errno with None -> "" | Some s -> sprintf ": errno=%d" s
and ctx_str = match ctx with None -> "" | Some s -> sprintf ": %s" s in
if compare min_level level <= 0 then begin
printf "%s%s%s: %s\n" level_str ctx_str errno_str msg;
flush stdout;
end
let stdio_progress _ctx what percent dne total =
let nl = if dne = total then "\n" else "" in
printf "\rProgress %s %d%% (%Ld/%Ld)%s" what percent dne total nl;
flush stdout
let create_stdio_logger ?(level=Info) () =
let cbs = {
vmessage = stdio_vmessage level;
progress = stdio_progress; } in
create "Xentoollog.stdio_logger" cbs
let do_test level =
let lgr = create_stdio_logger ~level:level () in
begin
test lgr;
end
let () =
let debug_level = ref Info in
let speclist = [
("-v", Arg.Unit (fun () -> debug_level := Debug), "Verbose");
("-q", Arg.Unit (fun () -> debug_level := Critical), "Quiet");
] in
let usage_msg = "usage: xtl [OPTIONS]" in
Arg.parse speclist (fun _ -> ()) usage_msg;
do_test !debug_level