tools/ocaml: cleanup to reduce compiler warnings
PATCH 1/1 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.
--- tools/ocaml/libs/xb/xb.ml | 10 +++--- tools/ocaml/test/dmesg.ml | 1 - tools/ocaml/test/list_domains.ml | 2 -- tools/ocaml/test/raise_exception.ml | 2 -- tools/ocaml/test/send_debug_keys.ml | 2 -- tools/ocaml/test/xtl.ml | 5 ++- tools/ocaml/xenstored/connections.ml | 8 ++--- tools/ocaml/xenstored/domains.ml | 2 +- tools/ocaml/xenstored/logging.ml | 2 +- tools/ocaml/xenstored/parse_arg.ml | 2 +- tools/ocaml/xenstored/process.ml | 48 ++++++++++++++-------------- tools/ocaml/xenstored/store.ml | 2 +- tools/ocaml/xenstored/syslog.ml | 1 - tools/ocaml/xenstored/transaction.ml | 6 ++-- tools/ocaml/xenstored/trie.ml | 14 ++++---- tools/ocaml/xenstored/xenstored.ml | 8 ++--- 16 files changed, 53 insertions(+), 62 deletions(-)
tools/ocaml/libs/xb/xb.ml +5 -5
@@ -69,13 +69,13 @@ let reconnect t = match t.backend with let queue con pkt = Queue.push pkt con.pkt_out -let read_fd back con b len = +let read_fd back _con b len = let rd = Unix.read back.fd b 0 len in if rd = 0 then raise End_of_file; rd -let read_mmap back con b len = +let read_mmap back _con b len = let s = Bytes.make len '\000' in let rd = Xs_ring.read back.mmap s len in Bytes.blit s 0 b 0 rd;
@@ -89,10 +89,10 @@ let read con b len = | Fd backfd -> read_fd backfd con b len | Xenmmap backmmap -> read_mmap backmmap con b len -let write_fd back con b len = +let write_fd back _con b len = Unix.write_substring back.fd b 0 len -let write_mmap back con s len = +let write_mmap back _con s len = let ws = Xs_ring.write_substring back.mmap s len in if ws > 0 then back.eventchn_notify ();
@@ -128,7 +128,7 @@ let input con = let to_read = match con.partial_in with | HaveHdr partial_pkt -> Partial.to_complete partial_pkt - | NoHdr (i, buf) -> i in + | NoHdr (i, _) -> i in (* try to get more data from input stream *) let b = Bytes.make to_read '\000' in
tools/ocaml/test/dmesg.ml +0 -1
@@ -1,4 +1,3 @@ -open Printf let _ = Xenlight.register_exceptions ();
tools/ocaml/test/list_domains.ml +0 -2
@@ -1,6 +1,4 @@ -open Arg open Printf -open Xenlight let bool_as_char b c = if b then c else '-'
tools/ocaml/test/raise_exception.ml +0 -2
@@ -1,6 +1,4 @@ open Printf -open Xentoollog -open Xenlight let _ = try
tools/ocaml/test/send_debug_keys.ml +0 -2
@@ -1,6 +1,4 @@ -open Arg open Printf -open Xenlight let send_keys ctx s = printf "Sending debug key %s\n" s;
tools/ocaml/test/xtl.ml +2 -3
@@ -1,4 +1,3 @@ -open Arg open Printf open Xentoollog
@@ -11,7 +10,7 @@ let stdio_vmessage min_level level errno ctx msg = flush stdout; end -let stdio_progress ctx what percent dne total = +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
@@ -35,6 +34,6 @@ let () = ("-q", Arg.Unit (fun () -> debug_level := Critical), "Quiet"); ] in let usage_msg = "usage: xtl [OPTIONS]" in - Arg.parse speclist (fun s -> ()) usage_msg; + Arg.parse speclist (fun _ -> ()) usage_msg; do_test !debug_level
tools/ocaml/xenstored/connections.ml +4 -4
@@ -31,7 +31,7 @@ let create () = { watches = Trie.create () } -let add_anonymous cons fd can_write = +let add_anonymous cons fd _can_write = let xbcon = Xenbus.Xb.open_fd fd in let con = Connection.create xbcon None in Hashtbl.add cons.anonymous (Xenbus.Xb.get_fd xbcon) con
@@ -91,7 +91,7 @@ let del_domain cons id = debug "del domain %u: %s" id (Printexc.to_string exn) let iter_domains cons fct = - Hashtbl.iter (fun k c -> fct c) cons.domains + Hashtbl.iter (fun _ c -> fct c) cons.domains let iter_anonymous cons fct = Hashtbl.iter (fun _ c -> fct c) cons.anonymous
@@ -101,7 +101,7 @@ let iter cons fct = let has_more_work cons = Hashtbl.fold - (fun id con acc -> + (fun _id con acc -> if Connection.has_more_work con then con :: acc else acc) cons.domains []
@@ -142,7 +142,7 @@ let fire_watches cons path recurse = | None -> () | Some watches -> List.iter (fun w -> Connection.fire_watch w path) watches in - let fire_rec x = function + let fire_rec _x = function | None -> () | Some watches -> List.iter (fun w -> Connection.fire_single_watch w) watches
tools/ocaml/xenstored/domains.ml +1 -1
@@ -119,7 +119,7 @@ let cleanup doms = ) !dead_dom; !notify, !dead_dom -let resume doms domid = +let resume _doms _domid = () let create doms domid mfn port =
tools/ocaml/xenstored/logging.ml +1 -1
@@ -98,7 +98,7 @@ let make_file_logger log_file log_nb_files log_nb_lines log_nb_chars post_rotate log_rotate channel log_file log_nb_files; (post_rotate (): unit); counter := 0 in - let write ?level s = + let write ?level:_ s = let s = if log_nb_chars > 0 then truncate_line log_nb_chars s else s in let s = s ^ "\n" in output_string !channel s;
tools/ocaml/xenstored/parse_arg.ml +1 -1
@@ -57,7 +57,7 @@ let do_argv = ("--use-select", Arg.Unit (fun () -> use_select := true), "Use select instead of poll"); (* for backward compatibility and testing *) ] in let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart] [--disable-socket] [--use-select]" in - Arg.parse speclist (fun s -> ()) usage_msg; + Arg.parse speclist (fun _ -> ()) usage_msg; { domain_init = !domain_init; activate_access_log = !activate_access_log;
tools/ocaml/xenstored/process.ml +24 -24
175 lines not on this page · raw message
tools/ocaml/xenstored/store.ml +1 -1
@@ -473,7 +473,7 @@ let incr_transaction_abort store = let stats store = let nb_nodes = ref 0 in - traversal store.root (fun path node -> + traversal store.root (fun _path _node -> incr nb_nodes ); !nb_nodes, store.stat_transaction_abort, store.stat_transaction_coalesce
tools/ocaml/xenstored/syslog.ml +0 -1
@@ -13,7 +13,6 @@ *) type level = Emerg | Alert | Crit | Err | Warning | Notice | Info | Debug -type options = Cons | Ndelay | Nowait | Odelay | Perror | Pid type facility = Auth | Authpriv | Cron | Daemon | Ftp | Kern | Local0 | Local1 | Local2 | Local3 | Local4 | Local5 | Local6 | Local7
tools/ocaml/xenstored/transaction.ml +3 -3
@@ -60,7 +60,7 @@ let test_coalesce oldroot currentroot optpath = let pnode = Store.Path.get_node currentroot (Store.Path.get_parent path) in match pnode with | None -> false (* ok it doesn't exists, just bail out. *) - | Some pnode -> true + | Some _ -> true ) | _ -> false
@@ -103,7 +103,7 @@ let oldest_short_running_transaction () = let rec last = function | [] -> None | [x] -> Some x - | x :: xs -> last xs + | _ :: xs -> last xs in last !short_running_txns let trim_short_running_transactions txn =
@@ -196,7 +196,7 @@ let commit ~con t = let has_commited = match t.ty with | No -> true - | Full (id, oldstore, cstore) -> (* "cstore" meaning current canonical store *) + | Full (_id, oldstore, cstore) -> (* "cstore" meaning current canonical store *) let commit_partial oldroot cstore store = (* get the lowest path of the query and verify that it hasn't been modified by others transactions. *)
tools/ocaml/xenstored/trie.ml +7 -7
@@ -21,7 +21,7 @@ struct children: ('a,'b) t list; } - let create key value = { + let _create key value = { key = key; value = Some value; children = [];
@@ -33,20 +33,20 @@ struct children = [] } - let get_key node = node.key + let _get_key node = node.key let get_value node = match node.value with | None -> raise Not_found | Some value -> value - let get_children node = node.children + let _get_children node = node.children let set_value node value = { node with value = Some value } let set_children node children = { node with children = children } - let add_child node child = + let _add_child node child = { node with children = child :: node.children } end
@@ -77,14 +77,14 @@ let remove_node nodes key = let create () = [] let rec iter f tree = - let rec aux node = + let aux node = f node.Node.key node.Node.value; iter f node.Node.children in List.iter aux tree let rec map f tree = - let rec aux node = + let aux node = let value = match node.Node.value with | None -> None
@@ -95,7 +95,7 @@ let rec map f tree = List.filter (fun n -> n.Node.value <> None || n.Node.children <> []) (List.map aux tree) let rec fold f tree acc = - let rec aux accu node = + let aux accu node = fold f node.Node.children (f node.Node.key node.Node.value accu) in List.fold_left aux acc tree
tools/ocaml/xenstored/xenstored.ml +4 -4
@@ -311,8 +311,8 @@ let _ = Select.use_poll (not cf.use_select); Sys.set_signal Sys.sighup (Sys.Signal_handle sighup_handler); - Sys.set_signal Sys.sigterm (Sys.Signal_handle (fun i -> quit := true)); - Sys.set_signal Sys.sigusr1 (Sys.Signal_handle (fun i -> sigusr1_handler store)); + Sys.set_signal Sys.sigterm (Sys.Signal_handle (fun _ -> quit := true)); + Sys.set_signal Sys.sigusr1 (Sys.Signal_handle (fun _ -> sigusr1_handler store)); Sys.set_signal Sys.sigpipe Sys.Signal_ignore; if cf.activate_access_log then begin
@@ -328,10 +328,10 @@ let _ = let process_special_fds rset = let accept_connection can_write fd = - let (cfd, addr) = Unix.accept fd in + let (cfd, _addr) = Unix.accept fd in debug "new connection through socket"; Connections.add_anonymous cons cfd can_write - and handle_eventchn fd = + and handle_eventchn _fd = let port = Event.pending eventchn in debug "pending port %d" (Xeneventchn.to_int port); finally (fun () ->
Signature · 7 lines
2.19.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Christian Lindig
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)
Quoted 5 lines
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 <[email protected]>
Very nice!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings [and 1 more messages]
Wei Liu writes ("Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings"):
Quoted 2 lines · Christian Lindig
Quoted 1 line
This commit cleans up code to reduce compiler warnings:
...
Quoted 3 lines
Acked-by Wei Liu <[email protected]>Very nice!
Christian Lindig writes ("Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings"):
Quoted 1 line
Ping. Any chance getting this in, Ian?
Thanks for the ping.
I tried to commit this patch but
mariner:xen.git> git-am ~/News/t
Applying: tools/ocaml: cleanup to reduce compiler warnings
error: patch failed: tools/ocaml/libs/xb/xb.ml:69
error: tools/ocaml/libs/xb/xb.ml: patch does not apply
error: patch failed: tools/ocaml/test/dmesg.ml:1
error: tools/ocaml/test/dmesg.ml: patch does not apply
...
That's with a copy of the patch fished from my personal colo server's view of xen-devel.
I think either the message must have been mangled by Citrix's mail system on the way out of Citrix, or the patch no longer applies.
Can you double check and maybe provide the patch as an attachment or a git branch or something ?
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings [and 1 more messages]
Quoted 23 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH 1/1]
tools/ocaml: cleanup to reduce compiler warnings"):Quoted 2 lines · Christian Lindig
Quoted 1 line
This commit cleans up code to reduce compiler warnings:
...
Quoted 3 lines
Acked-by Wei Liu <[email protected]>Very nice!
Christian Lindig writes ("Re: [PATCH 1/1]
tools/ocaml: cleanup to reduce compiler warnings"):Quoted 1 line
Ping. Any chance getting this in, Ian?
Thanks for the ping.
I tried to commit this patch but
mariner:xen.git> git-am ~/News/t
Applying:tools/ocaml: cleanup to reduce compiler warnings
error: patch failed:tools/ocaml/libs/xb/xb.ml:69
error:tools/ocaml/libs/xb/xb.ml: patch does not apply
error: patch failed:tools/ocaml/test/dmesg.ml:1
error:tools/ocaml/test/dmesg.ml: patch does not apply
...
Quoted 9 lines
That's with a copy of the patch fished from my personal colo server's view of xen-devel.
I think either the message must have been mangled by Citrix's mail system on the way out of Citrix, or the patch no longer applies.
Can you double check and maybe provide the patch as an attachment or a git branch or something ?
This patch is already applied.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings [and 1 more messages]
Wei Liu writes ("Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings [and 1 more messages]"):
Quoted 1 line
This patch is already applied.
Oh, that would explain it. I did check git-log but not thoroughly enough.
Sorry for the noise.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/1] tools/ocaml: cleanup to reduce compiler warnings [and 1 more messages]
In reply to Ian JacksonQuoted 21 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH 1/1]
tools/ocaml: cleanup to reduce compiler warnings"):Quoted 2 lines · Christian Lindig
Quoted 1 line
This commit cleans up code to reduce compiler warnings:
...
Quoted 3 lines
Acked-by Wei Liu <[email protected]>Very nice!
Christian Lindig writes ("Re: [PATCH 1/1]
tools/ocaml: cleanup to reduce compiler warnings"):Quoted 1 line
Ping. Any chance getting this in, Ian?
Thanks for the ping.
I tried to commit this patch but
mariner:xen.git> git-am ~/News/t
Applying:tools/ocaml: cleanup to reduce compiler warnings
error: patch failed:tools/ocaml/libs/xb/xb.ml:69
error:tools/ocaml/libs/xb/xb.ml: patch does not apply
error: patch failed:tools/ocaml/test/dmesg.ml:1
error:tools/ocaml/test/dmesg.ml: patch does not apply
...
Quoted 8 lines
That's with a copy of the patch fished from my personal colo server's view of xen-devel.
I think either the message must have been mangled by Citrix's mail system on the way out of Citrix, or the patch no longer applies.
Can you double check and maybe provide the patch as an attachment or a git branch or something ?
That's because Wei committed it 9 days ago.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel