Skip to content

Commit fb59aaf

Browse files
ndrs-pstkrish2718
authored andcommitted
[nrf fromtree] net: wifi: shell: enhance consistency in cmd_wifi_dpp_ap_auth_init
The `cmd_wifi_dpp_ap_auth_init` function was added but is not yet aligned with others. This update enhances consistency with the following changes: - Unified the order of declaration for `opt`, `opt_index`, `state`, and `long_options`. - Wrapped lines in the `long_options` declaration to prevent them from extending too far to the right. - Applied `struct option` as `static const` - Unified the wrapping of `getopt_long` calls, regardless of the length of the `options` string. - Using `getopt_state` to access `optarg` and also `optopt` offers a better alternative to direct global access. Signed-off-by: Pisit Sawangvonganan <[email protected]> (cherry picked from commit 7d19539)
1 parent 54e3abd commit fb59aaf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,24 +2617,27 @@ static int cmd_wifi_dpp_ap_qr_code(const struct shell *sh, size_t argc, char *ar
26172617

26182618
static int cmd_wifi_dpp_ap_auth_init(const struct shell *sh, size_t argc, char *argv[])
26192619
{
2620-
int ret = 0;
2621-
struct net_if *iface = net_if_get_wifi_sap();
2622-
struct wifi_dpp_params params = {0};
26232620
int opt;
26242621
int opt_index = 0;
26252622
struct getopt_state *state;
2626-
static struct option long_options[] = {{"peer", required_argument, 0, 'p'}, {0, 0, 0, 0}};
2623+
static const struct option long_options[] = {
2624+
{"peer", required_argument, 0, 'p'},
2625+
{0, 0, 0, 0}};
2626+
int ret = 0;
2627+
struct net_if *iface = net_if_get_wifi_sap();
2628+
struct wifi_dpp_params params = {0};
26272629

26282630
params.action = WIFI_DPP_AUTH_INIT;
26292631

2630-
while ((opt = getopt_long(argc, argv, "p:", long_options, &opt_index)) != -1) {
2632+
while ((opt = getopt_long(argc, argv, "p:",
2633+
long_options, &opt_index)) != -1) {
26312634
state = getopt_state_get();
26322635
switch (opt) {
26332636
case 'p':
2634-
params.auth_init.peer = shell_strtol(optarg, 10, &ret);
2637+
params.auth_init.peer = shell_strtol(state->optarg, 10, &ret);
26352638
break;
26362639
default:
2637-
PR_ERROR("Invalid option %c\n", optopt);
2640+
PR_ERROR("Invalid option %c\n", state->optopt);
26382641
return -EINVAL;
26392642
}
26402643

0 commit comments

Comments
 (0)