diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2026-04-10 00:12:50 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2026-04-17 23:45:49 +0300 |
| commit | 9c34ecf4a52379520d30b024c199f5ca6c5b38af (patch) | |
| tree | ca01e66f98ee90a30ebf0adef1facdad617bae79 /lib/utils/mu-command-handler.cc | |
| parent | 08ed7d2a8cd0a250cba7d0d918a7ebeaf778fc10 (diff) | |
lib/utils: small cleanupsrelease/1.12
Fix some static analysis warnings
Diffstat (limited to 'lib/utils/mu-command-handler.cc')
| -rw-r--r-- | lib/utils/mu-command-handler.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/utils/mu-command-handler.cc b/lib/utils/mu-command-handler.cc index 927df0b..6088280 100644 --- a/lib/utils/mu-command-handler.cc +++ b/lib/utils/mu-command-handler.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2020-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> +** Copyright (C) 2020-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -36,8 +36,8 @@ Command::string_vec_arg(const std::string& name) const std::vector<std::string> vec; for (const auto& item : val->list()) { if (!item.stringp()) { - // mu_warning("command: non-string in string-list for {}: {}", - // name, to_string()); + mu_warning("command: non-string in string-list for {}: {}", + name, to_string()); return Nothing; } else vec.emplace_back(item.string()); @@ -63,7 +63,6 @@ validate(const CommandHandler::CommandInfoMap& cmap, // // so, we're looking for the odd-numbered parameters. const auto param_it = cmd.find_arg(argname); - const auto&& param_val = std::next(param_it); // it's an error when a required parameter is missing. if (param_it == cmd.cend()) { if (arginfo.required) @@ -73,6 +72,13 @@ validate(const CommandHandler::CommandInfoMap& cmap, continue; // not required } + // the keyword is present; its value must follow it. + const auto param_val = std::next(param_it); + if (param_val == cmd.cend()) + return Err(Error::Code::Command, + "missing value for parameter {} in command '{}'", + argname, cmd.to_string()); + // the types must match, but the 'nil' symbol is acceptable as "no value" if (param_val->type() != arginfo.type && !(param_val->nilp())) return Err(Error::Code::Command, |
