From b1681478348ea74cb6abc3426f00415546e6bd55 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 21 Apr 2017 13:19:49 +0100 Subject: [PATCH] generator: Don't permit certain String/stringt combinations. After the previous commit it become possible to construct various "impossible" argument types, such as lists of FileIn strings. This commit prevents these from happening. --- generator/checks.ml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/generator/checks.ml b/generator/checks.ml index 788a11624..c30790dac 100644 --- a/generator/checks.ml +++ b/generator/checks.ml @@ -154,6 +154,29 @@ let () = List.iter check_arg_type args; ) (actions |> daemon_functions); + (* Some String/stringt and StringList/stringt combinations are + * not permitted. + *) + List.iter ( + fun { name = name; style = _, args, _ } -> + let check_arg_type = function + (* Previously only DeviceList and FilenameList were special list + * types. We could permit more here in future. + *) + | StringList (FileIn, _) + | StringList (FileOut, _) + | StringList (Mountable, _) + | StringList (Pathname, _) + | StringList (Dev_or_Path, _) + | StringList (Mountable_or_Path, _) + | StringList (Key, _) + | StringList (GUID, _) -> + failwithf "StringList (t, _) is not permitted for %s." name + | _ -> () + in + List.iter check_arg_type args + ) actions; + (* Check short descriptions. *) List.iter ( fun { name = name; shortdesc = shortdesc } ->