posix: getopt: Set variable only if used

Only assign dash_prefix when PRINT_ERROR true.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2022-06-29 16:47:59 +03:00 committed by Carles Cufí
parent ea5f59f896
commit 6f831d542a

View file

@ -179,19 +179,21 @@ parse_long_options(struct getopt_state *state, char * const *nargv,
current_argv = state->place;
#ifdef GNU_COMPATIBLE
switch (dash_prefix) {
case D_PREFIX:
current_dash = "-";
break;
case DD_PREFIX:
current_dash = "--";
break;
case W_PREFIX:
current_dash = "-W ";
break;
default:
current_dash = "";
break;
if (PRINT_ERROR) {
switch (dash_prefix) {
case D_PREFIX:
current_dash = "-";
break;
case DD_PREFIX:
current_dash = "--";
break;
case W_PREFIX:
current_dash = "-W ";
break;
default:
current_dash = "";
break;
}
}
#endif
match = -1;