From: Richard Jones Date: Tue, 6 Oct 2009 14:17:26 +0000 (+0100) Subject: Replace failwith (sprintf...) with failwithf X-Git-Tag: 1.0.5~34 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=e9ea4c12eac574c7daba52e93654eb2166c2e4cf;p=virt-top.git Replace failwith (sprintf...) with failwithf --- diff --git a/virt-top/virt_top.ml b/virt-top/virt_top.ml index 353c098..1a39e06 100644 --- a/virt-top/virt_top.ml +++ b/virt-top/virt_top.ml @@ -80,9 +80,8 @@ let sort_order_of_cli = function | "netrx" -> NetRX | "nettx" -> NetTX | "blockrdrq" -> BlockRdRq | "blockwrrq" -> BlockWrRq | str -> - failwith - (sprintf (f_ "%s: sort order should be: %s") - str "cpu|mem|time|id|name|netrx|nettx|blockrdrq|blockwrrq") + failwithf (f_ "%s: sort order should be: %s") + str "cpu|mem|time|id|name|netrx|nettx|blockrdrq|blockwrrq" let cli_of_sort_order = function | Processor -> "cpu" | Memory -> "mem" @@ -103,9 +102,7 @@ let display_of_cli = function | "block" -> BlockDisplay | "net" -> NetDisplay | str -> - failwith - (sprintf (f_ "%s: display should be %s") - str "task|pcpu|block|net") + failwithf (f_ "%s: display should be %s") str "task|pcpu|block|net" let cli_of_display = function | TaskDisplay -> "task" | PCPUDisplay -> "pcpu" diff --git a/virt-top/virt_top_utils.ml b/virt-top/virt_top_utils.ml index c668fb9..69f442f 100644 --- a/virt-top/virt_top_utils.ml +++ b/virt-top/virt_top_utils.ml @@ -35,6 +35,9 @@ let (-^) = Int64.sub let ( *^ ) = Int64.mul let (/^) = Int64.div +(* failwithf is a printf-like version of failwith. *) +let failwithf fs = ksprintf failwith fs + (* Input a whole file as a list of lines. *) let input_all_lines chan = let lines = ref [] in diff --git a/virt-top/virt_top_utils.mli b/virt-top/virt_top_utils.mli index 9cce00e..5af26d4 100755 --- a/virt-top/virt_top_utils.mli +++ b/virt-top/virt_top_utils.mli @@ -22,6 +22,9 @@ (* Filename concatenation. *) val (//) : string -> string -> string +(* failwithf is a printf-like version of failwith. *) +val failwithf : ('a, unit, string, 'b) format4 -> 'a + (* Read a configuration file as a list of (lineno, key, value) pairs. * If the config file is missing this returns an empty list. *)