search for: invalid_arg

Displaying 20 results from an estimated 99 matches for "invalid_arg".

2016 Jul 18
2
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...is used. IMHO either add a new M".." ([M]edium or [T]runcated or [D]ash or ...), or turn S to get a string instead. > - let validate_key key = > - if String.length key == 0 || key == "-" || key == "--" > - || key.[0] != '-' then > - invalid_arg (sprintf "invalid option key: '%s'" key) > + let validate_key = function > + | L"" -> invalid_arg "Getopt spec: invalid empty long option" > + | L"help" -> invalid_arg "Getopt spec: should not have L\"help\""...
2016 Jul 18
1
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
On Monday, 18 July 2016 14:43:03 CEST Richard W.M. Jones wrote: > > > - let validate_key key = > > > - if String.length key == 0 || key == "-" || key == "--" > > > - || key.[0] != '-' then > > > - invalid_arg (sprintf "invalid option key: '%s'" key) > > > + let validate_key = function > > > + | L"" -> invalid_arg "Getopt spec: invalid empty long option" > > > + | L"help" -> invalid_arg "Getopt spec: should not h...
2016 Jul 18
0
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...nk there is any other place in the code where the M option would be handled differently from the L option. > > - let validate_key key = > > - if String.length key == 0 || key == "-" || key == "--" > > - || key.[0] != '-' then > > - invalid_arg (sprintf "invalid option key: '%s'" key) > > + let validate_key = function > > + | L"" -> invalid_arg "Getopt spec: invalid empty long option" > > + | L"help" -> invalid_arg "Getopt spec: should not have L\"hel...
2017 Jul 31
0
[PATCH v11 03/10] daemon: utils: New functions unix_canonical_path, utf16le_to_utf8 and tests.
...ength is odd and the last character is ASCII NUL, just + * drop that. (If it's not ASCII NUL, then there's an error) + *) + let len = String.length instr in + let instr = + if len mod 1 = 1 then ( + if instr.[len-1] = '\000' then String.sub instr 0 (len-1) + else invalid_arg "input is not a valid UTF16-LE string: length is odd" + ) else instr in + + (* The length should now be even. If the last two bytes are + * '\0\0' then assume it's a NUL-terminated string from the + * Windows registry and drop both characters. + *) + let len = Stri...
2015 Jul 01
4
[PATCH 1/2] mllib: add and use last_part_of
...= *) let mkinitrd_kv = let modpath = kernel.ki_modpath in - let len = String.length modpath in - try - let i = String.rindex modpath '/' in - String.sub modpath (i+1) (len - (i+1)) - with - Not_found -> - invalid_arg (sprintf "invalid module path: %s" modpath) in + match last_part_of modpath '/' with + | Some x -> x + | None -> invalid_arg (sprintf "invalid module path: %s" modpath) in if g#is_file ~followsymlinks:true "/sbin/dracut" then...
2016 Jul 15
5
[PATCH 0/3] mllib: Various fixes and changes to Getopt module.
The second patch is obviously not complete yet - for discussion only. Rich.
2016 Jul 18
4
[PATCH 1/3] mllib: Getopt: point to man page as additional help
On error, point also to the man page of the current tool in addition to '$TOOL --help'. --- mllib/getopt-c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c index bf40f91..3efd5d3 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -69,8 +69,8 @@ cleanup_option_list (void *ptr) static void __attribute__((noreturn))
2023 May 20
1
[libguestfs-common PATCH] Add support for OCaml 5.0
...(+), 2 deletions(-) diff --git a/mlstdutils/std_utils.ml b/mlstdutils/std_utils.ml index 0d2fa22..86b21a7 100644 --- a/mlstdutils/std_utils.ml +++ b/mlstdutils/std_utils.ml @@ -341,12 +341,12 @@ module List = struct | x::xs, y::ys, z::zs -> (x, y, z) :: combine3 xs ys zs | _ -> invalid_arg "combine3" - let rec assoc_lbl ?(cmp = Pervasives.compare) ~default x = function + let rec assoc_lbl ?(cmp = Stdlib.compare) ~default x = function | [] -> default | (y, y') :: _ when cmp x y = 0 -> y' | _ :: ys -> assoc_lbl ~cmp ~default x ys...
2016 Jul 18
4
[PATCH v2 0/3] mllib: Various fixes and changes to Getopt module.
v1 -> v2: - Further fixes to Getopt int parsing. - Completed the L/S changes. - Fixed the test suite so it passes now. Also we don't need the special-case tests for 64 bit arch. Rich.
2017 Feb 07
1
Re: [PATCH v2 1/7] mllib: factorize code to add Checksum.get_checksum function
...(-) > > diff --git a/mllib/checksums.ml b/mllib/checksums.ml > index 1009e131c..bee829085 100644 > --- a/mllib/checksums.ml > +++ b/mllib/checksums.ml > @@ -45,14 +45,13 @@ let of_string csum_type csum_value = > | "sha512" -> SHA512 csum_value > | _ -> invalid_arg csum_type > > -let verify_checksum csum ?tar filename = > - let prog, csum_ref = > +let do_compute_checksum csum ?tar filename = > + let prog = > match csum with > - | SHA1 c -> "sha1sum", c > - | SHA256 c -> "sha256sum", c > -...
2015 Jul 01
0
Re: [PATCH 1/2] mllib: add and use last_part_of
...gt; let modpath = kernel.ki_modpath in > - let len = String.length modpath in > - try > - let i = String.rindex modpath '/' in > - String.sub modpath (i+1) (len - (i+1)) > - with > - Not_found -> > - invalid_arg (sprintf "invalid module path: %s" modpath) in > + match last_part_of modpath '/' with > + | Some x -> x > + | None -> invalid_arg (sprintf "invalid module path: %s" modpath) in That should probably be 'error' actually, but th...
2016 Jul 18
0
[PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
..._ -> () + | L _ as arg -> print_endline (string_of_option_name arg) ) args ) h.specs; exit 0 -(* Skip any leading '-' characters when comparing command line args. *) -let skip_dashes str = - let n = String.length str in - let rec loop i = - if i >= n then invalid_arg "skip_dashes" - else if String.unsafe_get str i = '-' then loop (i+1) - else i - in - let i = loop 0 in - if i = 0 then str - else String.sub str i (n-i) - let compare_command_line_args a b = - compare (String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b...
2015 Jul 01
1
Re: [PATCH 1/2] mllib: add and use last_part_of
...i_modpath in > > - let len = String.length modpath in > > - try > > - let i = String.rindex modpath '/' in > > - String.sub modpath (i+1) (len - (i+1)) > > - with > > - Not_found -> > > - invalid_arg (sprintf "invalid module path: %s" modpath) in > > + match last_part_of modpath '/' with > > + | Some x -> x > > + | None -> invalid_arg (sprintf "invalid module path: %s" modpath) in > > That should probably be 'er...
2016 Jul 18
3
[PATCH v4 0/2] mllib: Various fixes and changes to Getopt module.
v3 -> v4: - Pushed the first patch upstream since it was ACKed. - Prevent use of M except for the special virt-v2v options. - Sort the options after added --help etc. - Make corresponding fixes to the tests. Rich.
2016 Jul 18
4
[PATCH v3 0/3] mllib: Various fixes and changes to Getopt module.
v2 -> v3: - Add M variant and test it. Rich.
2016 Jul 11
0
Re: [PATCH v2] OCaml tools: add and use a Getopt module
...C-safe as far as I can tell. > +let parse_argv argv specs ?anon_fun usage_msg = > + (* Sanity check the input *) > + let validate_key key = > + if String.length key == 0 || key == "-" || key == "--" > + || key.[0] != '-' then > + raise (Invalid_argument (sprintf "invalid option key: '%s'" key)) Whereever you've written 'raise (Invalid_argument ...)' you can replace it with 'invalid_arg ...'. > + let specs = specs @ [ > + (* Handled internally by getopt_parse. *) > + [ "-h"; &qu...
2016 Nov 04
0
[PATCH 1/5] mllib: compute checksum of file inside tar
...2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mllib/checksums.ml b/mllib/checksums.ml index dfa8c3a..9fcff2f 100644 --- a/mllib/checksums.ml +++ b/mllib/checksums.ml @@ -45,7 +45,7 @@ let of_string csum_type csum_value = | "sha512" -> SHA512 csum_value | _ -> invalid_arg csum_type -let verify_checksum csum filename = +let verify_checksum csum ?(tar = "") filename = let prog, csum_ref = match csum with | SHA1 c -> "sha1sum", c @@ -53,7 +53,13 @@ let verify_checksum csum filename = | SHA512 c -> "sha512sum", c...
2016 Nov 12
0
[PATCH v2 1/5] mllib: compute checksum of file inside tar
...2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mllib/checksums.ml b/mllib/checksums.ml index dfa8c3a..0907499 100644 --- a/mllib/checksums.ml +++ b/mllib/checksums.ml @@ -45,7 +45,7 @@ let of_string csum_type csum_value = | "sha512" -> SHA512 csum_value | _ -> invalid_arg csum_type -let verify_checksum csum filename = +let verify_checksum csum ?(tar) filename = let prog, csum_ref = match csum with | SHA1 c -> "sha1sum", c @@ -53,7 +53,14 @@ let verify_checksum csum filename = | SHA512 c -> "sha512sum", c in - let c...
2016 Dec 07
0
[PATCH v3 1/6] mllib: compute checksum of file inside tar
...2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mllib/checksums.ml b/mllib/checksums.ml index dfa8c3a..a6c995b 100644 --- a/mllib/checksums.ml +++ b/mllib/checksums.ml @@ -45,7 +45,7 @@ let of_string csum_type csum_value = | "sha512" -> SHA512 csum_value | _ -> invalid_arg csum_type -let verify_checksum csum filename = +let verify_checksum csum ?tar filename = let prog, csum_ref = match csum with | SHA1 c -> "sha1sum", c @@ -53,7 +53,14 @@ let verify_checksum csum filename = | SHA512 c -> "sha512sum", c in - let cmd...
2017 Jan 03
0
[PATCH 2/5] mllib: factorize code to add Checksum.get_checksum function
...changed, 12 insertions(+), 11 deletions(-) diff --git a/mllib/checksums.ml b/mllib/checksums.ml index dfa8c3ae7..3efc764b9 100644 --- a/mllib/checksums.ml +++ b/mllib/checksums.ml @@ -45,23 +45,21 @@ let of_string csum_type csum_value = | "sha512" -> SHA512 csum_value | _ -> invalid_arg csum_type -let verify_checksum csum filename = - let prog, csum_ref = - match csum with - | SHA1 c -> "sha1sum", c - | SHA256 c -> "sha256sum", c - | SHA512 c -> "sha512sum", c - in - +let get_checksum csum filename = + let prog = (string_of_c...