[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [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. Signed-off-by: Christian Lindig <christian.lindig@xxxxxxxxxx> --- 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(-) diff --git a/tools/ocaml/libs/xb/xb.ml b/tools/ocaml/libs/xb/xb.ml index ca738657df..104d319d77 100644 --- a/tools/ocaml/libs/xb/xb.ml +++ b/tools/ocaml/libs/xb/xb.ml @@ -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 diff --git a/tools/ocaml/test/dmesg.ml b/tools/ocaml/test/dmesg.ml index 864fac4b79..c868024c52 100644 --- a/tools/ocaml/test/dmesg.ml +++ b/tools/ocaml/test/dmesg.ml @@ -1,4 +1,3 @@ -open Printf let _ = Xenlight.register_exceptions (); diff --git a/tools/ocaml/test/list_domains.ml b/tools/ocaml/test/list_domains.ml index c82d40d967..c8974957fd 100644 --- a/tools/ocaml/test/list_domains.ml +++ b/tools/ocaml/test/list_domains.ml @@ -1,6 +1,4 @@ -open Arg open Printf -open Xenlight let bool_as_char b c = if b then c else '-' diff --git a/tools/ocaml/test/raise_exception.ml b/tools/ocaml/test/raise_exception.ml index f048a46dfc..5ef7fc0f13 100644 --- a/tools/ocaml/test/raise_exception.ml +++ b/tools/ocaml/test/raise_exception.ml @@ -1,6 +1,4 @@ open Printf -open Xentoollog -open Xenlight let _ = try diff --git a/tools/ocaml/test/send_debug_keys.ml b/tools/ocaml/test/send_debug_keys.ml index d05f208920..67b1605dfe 100644 --- a/tools/ocaml/test/send_debug_keys.ml +++ b/tools/ocaml/test/send_debug_keys.ml @@ -1,6 +1,4 @@ -open Arg open Printf -open Xenlight let send_keys ctx s = printf "Sending debug key %s\n" s; diff --git a/tools/ocaml/test/xtl.ml b/tools/ocaml/test/xtl.ml index 6f4d85b0e7..5f94a76a82 100644 --- a/tools/ocaml/test/xtl.ml +++ b/tools/ocaml/test/xtl.ml @@ -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 diff --git a/tools/ocaml/xenstored/connections.ml b/tools/ocaml/xenstored/connections.ml index 299826e7a9..f02ef6b526 100644 --- a/tools/ocaml/xenstored/connections.ml +++ b/tools/ocaml/xenstored/connections.ml @@ -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 diff --git a/tools/ocaml/xenstored/domains.ml b/tools/ocaml/xenstored/domains.ml index 71dde16afa..17fe2fa257 100644 --- a/tools/ocaml/xenstored/domains.ml +++ b/tools/ocaml/xenstored/domains.ml @@ -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 = diff --git a/tools/ocaml/xenstored/logging.ml b/tools/ocaml/xenstored/logging.ml index cc6f72d7ec..c5cba79e92 100644 --- a/tools/ocaml/xenstored/logging.ml +++ b/tools/ocaml/xenstored/logging.ml @@ -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; diff --git a/tools/ocaml/xenstored/parse_arg.ml b/tools/ocaml/xenstored/parse_arg.ml index 6e22c1623b..1803c3eda0 100644 --- a/tools/ocaml/xenstored/parse_arg.ml +++ b/tools/ocaml/xenstored/parse_arg.ml @@ -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; diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml index d813d7fd50..8a7e538893 100644 --- a/tools/ocaml/xenstored/process.ml +++ b/tools/ocaml/xenstored/process.ml @@ -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 t 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 t 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 t 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) diff --git a/tools/ocaml/xenstored/store.ml b/tools/ocaml/xenstored/store.ml index c6c874131d..f299ec6461 100644 --- a/tools/ocaml/xenstored/store.ml +++ b/tools/ocaml/xenstored/store.ml @@ -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 diff --git a/tools/ocaml/xenstored/syslog.ml b/tools/ocaml/xenstored/syslog.ml index abeace7296..a95da2fd7b 100644 --- a/tools/ocaml/xenstored/syslog.ml +++ b/tools/ocaml/xenstored/syslog.ml @@ -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 diff --git a/tools/ocaml/xenstored/transaction.ml b/tools/ocaml/xenstored/transaction.ml index 96f56f0c49..963734a653 100644 --- a/tools/ocaml/xenstored/transaction.ml +++ b/tools/ocaml/xenstored/transaction.ml @@ -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. *) diff --git a/tools/ocaml/xenstored/trie.ml b/tools/ocaml/xenstored/trie.ml index d9c9c2cc27..dc42535092 100644 --- a/tools/ocaml/xenstored/trie.ml +++ b/tools/ocaml/xenstored/trie.ml @@ -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 diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xenstored.ml index 7df02ed574..a4466c5b5c 100644 --- a/tools/ocaml/xenstored/xenstored.ml +++ b/tools/ocaml/xenstored/xenstored.ml @@ -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 () -> -- 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |