mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-21 01:06:58 +00:00
config: check that there are not unhandled parameters in a config
Return an error if we meet unexpected parameters in a config file Cc: Veronika Kabatova <vkabatov@redhat.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
ba98bae902
commit
2280a6eecf
1 changed files with 21 additions and 3 deletions
|
|
@ -401,20 +401,38 @@ int main(int argc, char *argv[], char *envp[])
|
|||
goto usage;
|
||||
|
||||
while (1) {
|
||||
char **_argv = NULL;
|
||||
int _argc = 0;
|
||||
|
||||
idx = -1;
|
||||
|
||||
switch (state) {
|
||||
case PARSING_GLOBAL_CONF:
|
||||
opt = getopt_long(global_cfg_argc, global_conf, short_opts, long_opts, &idx);
|
||||
_argc = global_cfg_argc;
|
||||
_argv = global_conf;
|
||||
break;
|
||||
case PARSING_USER_CONF:
|
||||
opt = getopt_long(user_cfg_argc, user_conf, short_opts, long_opts, &idx);
|
||||
_argc = user_cfg_argc;
|
||||
_argv = user_conf;
|
||||
break;
|
||||
case PARSING_ARGV:
|
||||
opt = getopt_long(argc, argv, short_opts, long_opts, &idx);
|
||||
_argc = argc;
|
||||
_argv = argv;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
opt = getopt_long(_argc, _argv, short_opts, long_opts, &idx);
|
||||
if (opt == -1) {
|
||||
switch (state) {
|
||||
case PARSING_GLOBAL_CONF:
|
||||
case PARSING_USER_CONF:
|
||||
if (optind < _argc) {
|
||||
pr_err("Unknown config parameter: %s\n", _argv[optind]);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (state < PARSING_ARGV) {
|
||||
state++;
|
||||
optind = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue