Commit acae0dc0 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Replace AssertFatal with static_assert for cmdline arguments check

Replace AssertFatal with static_assert for command line arguments definition
length check. The static assert will not allow the code to compile in case
the size is incorrect.

This could save some time in the future since its easy to forget to extend
CMDLINE_PARAMS_CHECK_DESC.
parent f5014696
......@@ -105,8 +105,9 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask)
paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC;
checkedparam_t cmdline_CheckParams[] = CMDLINE_PARAMS_CHECK_DESC;
static_assert(sizeofArray(cmdline_params) == sizeofArray(cmdline_CheckParams),
"cmdline_params and cmdline_CheckParams should have the same size");
int numparams = sizeofArray(cmdline_params);
AssertFatal(numparams == sizeofArray(cmdline_CheckParams), "Error in arrays size (%d!=%lu)\n", numparams, sizeofArray(cmdline_CheckParams));
config_set_checkfunctions(cmdline_params, cmdline_CheckParams, numparams);
config_get(cfg, cmdline_params, numparams, NULL);
nfapi_index = config_paramidx_fromname(cmdline_params, numparams, "nfapi");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment