]> xenbits.xensource.com Git - xen.git/commitdiff
tools/ocaml: cleanup to reduce compiler warnings
authorChristian Lindig <christian.lindig@citrix.com>
Wed, 14 Nov 2018 11:06:49 +0000 (11:06 +0000)
committerWei Liu <wei.liu2@citrix.com>
Wed, 14 Nov 2018 18:22:09 +0000 (18:22 +0000)
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>
16 files changed:
tools/ocaml/libs/xb/xb.ml
tools/ocaml/test/dmesg.ml
tools/ocaml/test/list_domains.ml
tools/ocaml/test/raise_exception.ml
tools/ocaml/test/send_debug_keys.ml
tools/ocaml/test/xtl.ml
tools/ocaml/xenstored/connections.ml
tools/ocaml/xenstored/domains.ml
tools/ocaml/xenstored/logging.ml
tools/ocaml/xenstored/parse_arg.ml
tools/ocaml/xenstored/process.ml
tools/ocaml/xenstored/store.ml
tools/ocaml/xenstored/syslog.ml
tools/ocaml/xenstored/transaction.ml
tools/ocaml/xenstored/trie.ml
tools/ocaml/xenstored/xenstored.ml

index ca738657df3b522e5c21ed2d8554a2823533a483..104d319d7747af51ad51bb072899201169db3367 100644 (file)
@@ -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
index 864fac4b79522ac704472bb142565d16392f79d4..c868024c52124cd01a7d668fbaeb9f10d9d796f8 100644 (file)
@@ -1,4 +1,3 @@
-open Printf
 
 let _ =
        Xenlight.register_exceptions ();
index c82d40d967409e35ab1991b4583f22f0b30792ec..c8974957fd38feb77a25c401f07456bc38afd496 100644 (file)
@@ -1,6 +1,4 @@
-open Arg
 open Printf
-open Xenlight
 
 let bool_as_char b c = if b then c else '-'
 
index f048a46dfc70cfe0893ca6b0a52fd77645e0e5aa..5ef7fc0f13bc132576abdbe8451749b8c4ffbc7e 100644 (file)
@@ -1,6 +1,4 @@
 open Printf
-open Xentoollog
-open Xenlight
 
 let _ =
   try
index d05f208920eaaf7bf51c31c2ecf1e41bf2c238aa..67b1605dfe201bf104ec8681abfabad359eb8dd7 100644 (file)
@@ -1,6 +1,4 @@
-open Arg
 open Printf
-open Xenlight
 
 let send_keys ctx s =
   printf "Sending debug key %s\n" s;
index 6f4d85b0e7aa4cd5ec7d023bad9c085d3402cf5a..5f94a76a829ced7c8862fcd93875cc81e2584c8a 100644 (file)
@@ -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
index 299826e7a9ef5189b0c269a1ef36ab32a4b6bb22..f02ef6b5267cf9e87f525c16d86a7f10ec445a7a 100644 (file)
@@ -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
index 71dde16afa83e8225e1fbfefe1646fbfa09d6c7e..17fe2fa25772b8fccfb9c5e9174fa3be92634766 100644 (file)
@@ -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 =
index cc6f72d7ece71a71dcc42dd962a92202d880900f..c5cba79e92f359d81d062a3c908f959131e94554 100644 (file)
@@ -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;
index 6e22c1623b4fba968d849507ab8162aba1f739ed..1803c3eda0c8f99fc6510355e166ae69e3bab13e 100644 (file)
@@ -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;
index d813d7fd505aab1ad3df1234fe9fc459991b8dc5..8a7e538893cea10c4445054908da9cc190018134 100644 (file)
@@ -83,7 +83,7 @@ let create_implicit_path t perm path =
        )
 
 (* packets *)
-let do_debug con t domains cons data =
+let do_debug con t _domains cons data =
        if not (Connection.is_dom0 con) && not !allow_debug
        then None
        else try match split None '\000' data with
@@ -104,7 +104,7 @@ let do_debug con t domains cons data =
        | _ -> None
        with _ -> None
 
-let do_directory con t domains cons data =
+let do_directory con t _domains _cons data =
        let path = split_one_path data con in
        let entries = Transaction.ls t (Connection.get_perm con) path in
        if List.length entries > 0 then
@@ -112,16 +112,16 @@ let do_directory con t domains cons data =
        else
                ""
 
-let do_read con t domains cons data =
+let do_read con t _domains _cons data =
        let path = split_one_path data con in
        Transaction.read t (Connection.get_perm con) path
 
-let do_getperms con t domains cons data =
+let do_getperms con t _domains _cons data =
        let path = split_one_path data con in
        let perms = Transaction.getperms t (Connection.get_perm con) path in
        Perms.Node.to_string perms ^ "\000"
 
-let do_getdomainpath con t domains cons data =
+let do_getdomainpath _con _t _domains _cons data =
        let domid =
                match (split None '\000' data) with
                | domid :: "" :: [] -> c_int_of_string domid
@@ -129,7 +129,7 @@ let do_getdomainpath con t domains cons data =
                in
        sprintf "/local/domain/%u\000" domid
 
-let do_write con t domains cons data =
+let do_write con t _domains _cons data =
        let path, value =
                match (split (Some 2) '\000' data) with
                | path :: value :: [] -> Store.Path.create path (Connection.get_path con), value
@@ -138,7 +138,7 @@ let do_write con t domains cons data =
        create_implicit_path t (Connection.get_perm con) path;
        Transaction.write t (Connection.get_perm con) path value
 
-let do_mkdir con t domains cons data =
+let do_mkdir con t _domains _cons data =
        let path = split_one_path data con in
        create_implicit_path t (Connection.get_perm con) path;
        try
@@ -146,14 +146,14 @@ let do_mkdir con t domains cons data =
        with
                Define.Already_exist -> ()
 
-let do_rm con t domains cons data =
+let do_rm con t _domains _cons data =
        let path = split_one_path data con in
        try
                Transaction.rm t (Connection.get_perm con) path
        with
                Define.Doesnt_exist -> ()
 
-let do_setperms con t domains cons data =
+let do_setperms con t _domains _cons data =
        let path, perms =
                match (split (Some 2) '\000' data) with
                | path :: perms :: _ ->
@@ -163,10 +163,10 @@ let do_setperms con t domains cons data =
                in
        Transaction.setperms t (Connection.get_perm con) path perms
 
-let do_error con t domains cons data =
+let do_error _con _t _domains _cons _data =
        raise Define.Unknown_operation
 
-let do_isintroduced con t domains cons data =
+let do_isintroduced _con _t domains _cons data =
        let domid =
                match (split None '\000' data) with
                | domid :: _ -> int_of_string domid
@@ -175,12 +175,12 @@ let do_isintroduced con t domains cons data =
        if domid = Define.domid_self || Domains.exist domains domid then "T\000" else "F\000"
 
 (* only in xen >= 4.2 *)
-let do_reset_watches con t domains cons data =
+let do_reset_watches con _t _domains _cons _data =
   Connection.del_watches con;
   Connection.del_transactions con
 
 (* only in >= xen3.3                                                                                    *)
-let do_set_target con domains cons data =
+let do_set_target con _t _domains cons data =
        if not (Connection.is_dom0 con)
        then raise Define.Permission_denied;
        match split None '\000' data with
@@ -254,11 +254,11 @@ let input_handle_error ~cons ~doms ~fct ~con ~t ~req =
        | Define.Invalid_path          -> reply_error "EINVAL"
        | Define.Already_exist         -> reply_error "EEXIST"
        | Define.Doesnt_exist          -> reply_error "ENOENT"
-       | Define.Lookup_Doesnt_exist s -> reply_error "ENOENT"
+       | Define.Lookup_Doesnt_exist _ -> reply_error "ENOENT"
        | Define.Permission_denied     -> reply_error "EACCES"
        | Not_found                    -> reply_error "ENOENT"
        | Invalid_Cmd_Args             -> reply_error "EINVAL"
-       | Invalid_argument i           -> reply_error "EINVAL"
+       | Invalid_argument _           -> reply_error "EINVAL"
        | Transaction_again            -> reply_error "EAGAIN"
        | Transaction_nested           -> reply_error "EBUSY"
        | Domain_not_match             -> reply_error "EINVAL"
@@ -293,7 +293,7 @@ let transaction_replay c t doms cons =
        | Transaction.No ->
                error "attempted to replay a non-full transaction";
                false
-       | Transaction.Full(id, oldstore, cstore) ->
+       | Transaction.Full(id, _oldstore, cstore) ->
                let tid = Connection.start_transaction c cstore in
                let replay_t = Transaction.make ~internal:true tid cstore in
                let con = sprintf "r(%d):%s" id (Connection.get_domstr c) in
@@ -351,7 +351,7 @@ let transaction_replay c t doms cons =
                        ignore @@ Connection.end_transaction c tid None
                )
 
-let do_watch con domains cons data =
+let do_watch con _t _domains cons data =
        let (node, token) =
                match (split None '\000' data) with
                | [node; token; ""]   -> node, token
@@ -360,7 +360,7 @@ let do_watch con t domains cons data =
        let watch = Connections.add_watch cons con node token in
        Packet.Ack (fun () -> Connection.fire_single_watch watch)
 
-let do_unwatch con domains cons data =
+let do_unwatch con _t _domains cons data =
        let (node, token) =
                match (split None '\000' data) with
                | [node; token; ""]   -> node, token
@@ -368,7 +368,7 @@ let do_unwatch con t domains cons data =
                in
        ignore @@ Connections.del_watch cons con node token
 
-let do_transaction_start con t domains cons data =
+let do_transaction_start con t _domains _cons _data =
        if Transaction.get_id t <> Transaction.none then
                raise Transaction_nested;
        let store = Transaction.get_store t in
@@ -397,7 +397,7 @@ let do_transaction_end con t domains cons data =
                        record_commit ~con ~tid:id ~before:oldstore ~after:cstore
        end
 
-let do_introduce con t domains cons data =
+let do_introduce con _t domains cons data =
        if not (Connection.is_dom0 con)
        then raise Define.Permission_denied;
        let (domid, mfn, port) =
@@ -419,7 +419,7 @@ let do_introduce con t domains cons data =
        if (Domain.get_remote_port dom) <> port || (Domain.get_mfn dom) <> mfn then
                raise Domain_not_match
 
-let do_release con t domains cons data =
+let do_release con _t domains cons data =
        if not (Connection.is_dom0 con)
        then raise Define.Permission_denied;
        let domid =
@@ -434,7 +434,7 @@ let do_release con t domains cons data =
        then Connections.fire_spec_watches cons "@releaseDomain"
        else raise Invalid_Cmd_Args
 
-let do_resume con t domains cons data =
+let do_resume con _t domains _cons data =
        if not (Connection.is_dom0 con)
        then raise Define.Permission_denied;
        let domid =
@@ -566,11 +566,11 @@ let do_input store cons doms con =
                Connection.incr_ops con;
        )
 
-let do_output store cons doms con =
+let do_output _store _cons _doms con =
        if Connection.has_output con then (
                if Connection.has_new_output con then (
                        let packet = Connection.peek_output con in
-                       let tid, rid, ty, data = Xenbus.Xb.Packet.unpack packet in
+                       let tid, _rid, ty, data = Xenbus.Xb.Packet.unpack packet in
                        (* As we don't log IO, do not call an unnecessary sanitize_data
                           info "[%s] <- %s \"%s\""
                                 (Connection.get_domstr con)
index c6c874131d1bb14cd6b5479f68b2b4392f3f734f..f299ec646124d3866b72e6e43a5af3cf5503f863 100644 (file)
@@ -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
index abeace7296f9d1b278aa817462735fbbb9d2accd..a95da2fd7b17bd0f2abf989eabef40c182774b9a 100644 (file)
@@ -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
index 96f56f0c49fd3c6ce8d12232155e83faa4a3bd11..963734a6534ae50508accb579770e9e836bb11ba 100644 (file)
@@ -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. *)
index d9c9c2cc278cc15c1b23479763fc7735aeeaa4b9..dc42535092d24b5657ae5022fb22465f63ffdb67 100644 (file)
@@ -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
index 7df02ed5744c91f6f50526bae201801be363b939..a4466c5b5ca9d955564e29128ec6c62367a1476a 100644 (file)
@@ -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 () ->