Skip to content
Commit ed562c53 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

kconfig: refactor option parse code



The current option parse code is clumsy.

The 's' option is separately handled in an if-conditional due to the
following code:

    input_mode = (enum input_mode)opt;

If 's' is moved to the switch statement, the invalid value 's' would
be assigned to the input_mode.

Another potential problem is that we are mixing 'enum input_mode' and
ASCII characters. They could overwrap if we add more input modes.

To separate them out, set the flag field of long options to a pointer
of input_mode_opt. For mode select options, getopt_long() returns 0,
which never causes overwrap with ASCII characters that represent short
options.

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 89145649
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