[PATCH] broadband-modem-qmi: allow prefix match for Modem images ending with '?'

Aleksander Morgado aleksander at aleksander.es
Wed Jun 14 22:36:25 UTC 2017


On Wed, Jun 14, 2017 at 10:20 PM, Dan Williams <dcbw at redhat.com> wrote:
> Assume that a modem image build_id "02.08.02.00_?" matches a pri build_id
> of "02.08.02.00_ATT" or "02.08.02.00_GENERIC".

LGTM

> ---
>  src/mm-broadband-modem-qmi.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
> index 8390b6f..0e060d9 100644
> --- a/src/mm-broadband-modem-qmi.c
> +++ b/src/mm-broadband-modem-qmi.c
> @@ -10151,6 +10151,28 @@ get_next_image_info (FirmwareCheckSupportContext *ctx)
>      qmi_message_dms_get_stored_image_info_input_unref (input);
>  }
>
> +static gboolean
> +match_images (const gchar *pri_id, const gchar *modem_id)
> +{
> +    gsize modem_id_len;
> +
> +    if (!pri_id || !modem_id)
> +        return FALSE;
> +
> +    if (g_str_equal (pri_id, modem_id))
> +        return TRUE;
> +
> +    /* If the Modem image build_id ends in '?' just use a prefix match.  eg,
> +     * assume that modem="02.08.02.00_?" matches pri="02.08.02.00_ATT" or
> +     * pri="02.08.02.00_GENERIC".
> +     */
> +    modem_id_len = strlen (modem_id);
> +    if (modem_id[modem_id_len - 1] != '?')
> +        return FALSE;
> +
> +    return strncmp (pri_id, modem_id, modem_id_len - 1) == 0;
> +}
> +
>  static void
>  list_stored_images_ready (QmiClientDms *client,
>                            GAsyncResult *res,
> @@ -10241,7 +10263,7 @@ list_stored_images_ready (QmiClientDms *client,
>                                               QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement,
>                                               j);
>
> -            if (g_str_equal (subimage_pri->build_id, subimage_modem->build_id)) {
> +            if (match_images (subimage_pri->build_id, subimage_modem->build_id)) {
>                  FirmwarePair *pair;
>
>                  mm_dbg ("Found pairing PRI+MODEM images with build ID '%s'", subimage_pri->build_id);
> --
> 2.9.4
> _______________________________________________
> ModemManager-devel mailing list
> ModemManager-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel



-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list