diff options
author | Dan Williams <dcbw@redhat.com> | 2013-03-25 13:47:00 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-03-27 08:25:13 -0500 |
commit | 7f1bea5fbf9ea25eeebb320e476d56ece44f276e (patch) | |
tree | 04ffc26ba666302b0f302017eddb0a82a8e3096f | |
parent | 3b3326bdf03a02822ac8d1e9e0ff08db2324c3ed (diff) | |
download | ModemManager-7f1bea5fbf9ea25eeebb320e476d56ece44f276e.tar.gz |
broadband-modem-qmi: zero-pad ESN to 8 characters
It's very likely to already be 8 characters, but if by some
chance it's 7, zero-pad like we do for AT+GSN responses in
the generic CDMA code.
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index 6d7efa2d0..c33f707dc 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -989,6 +989,7 @@ dms_get_ids_ready (QmiClientDms *client, QmiMessageDmsGetIdsOutput *output = NULL; GError *error = NULL; const gchar *str; + guint len; output = qmi_client_dms_get_ids_finish (client, res, &error); if (!output) { @@ -1022,13 +1023,23 @@ dms_get_ids_ready (QmiClientDms *client, if (qmi_message_dms_get_ids_output_get_esn (output, &str, NULL) && str[0] != '\0' && str[0] != '0') { g_free (ctx->self->priv->esn); - ctx->self->priv->esn = g_strdup (str); + len = strlen (str); + if (len == 7) + ctx->self->priv->esn = g_strdup_printf ("0%s", str); /* zero-pad to 8 chars */ + else if (len == 8) + ctx->self->priv->esn = g_strdup (str); + else + g_warn_if_reached (); } if (qmi_message_dms_get_ids_output_get_meid (output, &str, NULL) && str[0] != '\0' && str[0] != '0') { g_free (ctx->self->priv->meid); - ctx->self->priv->meid = g_strdup (str); + len = strlen (str); + if (len == 14) + ctx->self->priv->meid = g_strdup (str); + else + g_warn_if_reached (); } if (ctx->self->priv->imei) |