Skip to content

Commit 08fe69c

Browse files
ndrs-pstkartben
authored andcommitted
net: wifi: shell: enhance consistency in __wifi_args_to_params
Several arguments were added but have not yet been aligned with others in the same function. Hence, use `getopt_state` to access `optarg`, offering a better alternative to direct global access. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 5d9a0cb commit 08fe69c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
726726
}
727727
break;
728728
case 'a':
729-
params->anon_id = optarg;
729+
params->anon_id = state->optarg;
730730
params->aid_length = strlen(params->anon_id);
731731
if (params->aid_length > WIFI_ENT_IDENTITY_MAX_LEN) {
732732
PR_WARNING("anon_id too long (max %d characters)\n",
@@ -741,15 +741,15 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
741741
}
742742

743743
if (key_passwd_cnt == 0) {
744-
params->key_passwd = optarg;
744+
params->key_passwd = state->optarg;
745745
params->key_passwd_length = strlen(params->key_passwd);
746746
if (params->key_passwd_length > WIFI_ENT_PSWD_MAX_LEN) {
747747
PR_WARNING("key_passwd too long (max %d characters)\n",
748748
WIFI_ENT_PSWD_MAX_LEN);
749749
return -EINVAL;
750750
}
751751
} else if (key_passwd_cnt == 1) {
752-
params->key2_passwd = optarg;
752+
params->key2_passwd = state->optarg;
753753
params->key2_passwd_length = strlen(params->key2_passwd);
754754
if (params->key2_passwd_length > WIFI_ENT_PSWD_MAX_LEN) {
755755
PR_WARNING("key2_passwd too long (max %d characters)\n",
@@ -760,10 +760,10 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
760760
key_passwd_cnt++;
761761
break;
762762
case 'S':
763-
params->suiteb_type = atoi(optarg);
763+
params->suiteb_type = atoi(state->optarg);
764764
break;
765765
case 'V':
766-
params->eap_ver = atoi(optarg);
766+
params->eap_ver = atoi(state->optarg);
767767
if (params->eap_ver != 0U && params->eap_ver != 1U) {
768768
PR_WARNING("eap_ver error %d\n", params->eap_ver);
769769
return -EINVAL;
@@ -776,10 +776,10 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
776776
return -EINVAL;
777777
}
778778

779-
params->eap_identity = optarg;
779+
params->eap_identity = state->optarg;
780780
params->eap_id_length = strlen(params->eap_identity);
781781

782-
params->identities[params->nusers] = optarg;
782+
params->identities[params->nusers] = state->optarg;
783783
params->nusers++;
784784
if (params->eap_id_length > WIFI_ENT_IDENTITY_MAX_LEN) {
785785
PR_WARNING("eap identity too long (max %d characters)\n",
@@ -794,10 +794,10 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
794794
return -EINVAL;
795795
}
796796

797-
params->eap_password = optarg;
797+
params->eap_password = state->optarg;
798798
params->eap_passwd_length = strlen(params->eap_password);
799799

800-
params->passwords[params->passwds] = optarg;
800+
params->passwords[params->passwds] = state->optarg;
801801
params->passwds++;
802802
if (params->eap_passwd_length > WIFI_ENT_PSWD_MAX_LEN) {
803803
PR_WARNING("eap password length too long (max %d characters)\n",

0 commit comments

Comments
 (0)