static analyzer bit in options.c

Analyzer didn't like the use of strchr on an incomplete type.
Move the guts into a function in o_init.c.
This commit is contained in:
nhmall
2024-01-21 13:38:25 -05:00
parent 6f47094b8d
commit d4f04fbdc8
3 changed files with 14 additions and 10 deletions

View File

@@ -1089,4 +1089,16 @@ rename_disco(void)
return;
}
void
get_sortdisco(char *opts, boolean cnf)
{
const char *p = strchr(disco_order_let, flags.discosort);
if (!p)
flags.discosort = 'o', p = disco_order_let;
if (cnf)
Sprintf(opts, "%c", flags.discosort);
else
Strcpy(opts, disco_orders_descr[p - disco_order_let]);
}
/*o_init.c*/

View File

@@ -3683,16 +3683,7 @@ optfn_sortdiscoveries(
return optn_ok;
}
if (req == get_val || req == get_cnf_val) {
extern const char *const disco_orders_descr[]; /* o_init.c */
extern const char disco_order_let[];
const char *p = strchr(disco_order_let, flags.discosort);
if (!p)
flags.discosort = 'o', p = disco_order_let;
if (req == get_cnf_val)
Sprintf(opts, "%c", flags.discosort);
else
Strcpy(opts, disco_orders_descr[p - disco_order_let]);
get_sortdisco(opts, (req == get_cnf_val) ? TRUE : FALSE);
return optn_ok;
}
if (req == do_handler) {