Re: [PATCH 4/4] qmi: sim: implement change_passwd(ChangePin method)
Denis Kenzior <[email protected]>
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <[email protected]> |
Hi Ivo,
On 11/23/24 3:05 AM, Ivaylo Dimitrov wrote:
> ---
> drivers/qmimodem/sim.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/qmimodem/uim.h | 1 +
> 2 files changed, 77 insertions(+)
>
<snip>
>
> +static void qmi_change_passwd(struct ofono_sim *sim,
> + enum ofono_sim_password_type passwd_type,
> + const char *old_pwd, const char *new_pwd,
> + ofono_sim_lock_unlock_cb_t cb, void *user_data)
> +{
> + struct sim_data *data = ofono_sim_get_data(sim);
> + struct cb_data *cbd = cb_data_new(cb, user_data);
> + int old_pwd_len;
> + int new_pwd_len;
I changed these to uint8_t since strlen returns a 'size_t'
<snip>
> + switch (passwd_type) {
> + case OFONO_SIM_PASSWORD_SIM_PIN:
> + pin_id = 0x01;
> + break;
> + case OFONO_SIM_PASSWORD_SIM_PIN2:
> + pin_id = 0x02;
> + break;
> + default:
> + CALLBACK_WITH_CME_ERROR(cb, 4, cbd->data);
Added l_free(cbd) here
> + return;
> + }
> +
> + old_pwd_len = strlen(old_pwd);
> + new_pwd_len = strlen(new_pwd);
> +
> + /* info */
> + info1_len = sizeof(*info1) + old_pwd_len;
> + info2_len = sizeof(*info2) + new_pwd_len;
> + info_len = info1_len + info2_len;
> +
> + info1 = alloca(info_len);
> + info1->id = pin_id;
> + info1->length = (uint8_t) old_pwd_len;
Dropped the cast
> + memcpy(info1->pin, old_pwd, old_pwd_len);
> +
> + info2 = (void *)&info1->pin[old_pwd_len];
> + info2->length = (uint8_t) new_pwd_len;
Ditto
> + memcpy(info2->pin, new_pwd, new_pwd_len);
> +
> + param = qmi_param_new();
> + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, info_len, info1);
> +
Applied.
Regards,
-Denis