diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-12-05 17:36:18 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-01-16 11:24:14 +0100 |
commit | 99120ad04aa971257ab0dc4508354bb0664ffc86 (patch) | |
tree | 28e21204cd81dace55a6230fd36ef1348984c4a2 /src | |
parent | 396c86e44a63396664c11c346172364180b1a58f (diff) | |
download | external_libqmi-99120ad04aa971257ab0dc4508354bb0664ffc86.zip external_libqmi-99120ad04aa971257ab0dc4508354bb0664ffc86.tar.gz external_libqmi-99120ad04aa971257ab0dc4508354bb0664ffc86.tar.bz2 |
qmi-firmware-update: update error when image verification fails
Diffstat (limited to 'src')
-rw-r--r-- | src/qmi-firmware-update/qfu-image-factory.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/qmi-firmware-update/qfu-image-factory.c b/src/qmi-firmware-update/qfu-image-factory.c index 1ee7b6d..3250c70 100644 --- a/src/qmi-firmware-update/qfu-image-factory.c +++ b/src/qmi-firmware-update/qfu-image-factory.c @@ -29,15 +29,15 @@ qfu_image_factory_build (GFile *file, GCancellable *cancellable, GError **error) { - gchar *basename; - QfuImageType image_type; - QfuImage *image = NULL; + gchar *basename; + QfuImage *image = NULL; + GError *inner_error = NULL; g_assert (G_IS_FILE (file)); basename = g_file_get_basename (file); /* guessing image type based on the well known Gobi 1k and 2k - * filenames, and assumes anything else is a CWE image + * filenames, and assumes anything else could be a CWE image * * This is based on the types in gobi-loader's snooped magic strings: * 0x05 => "amss.mbn" @@ -45,27 +45,23 @@ qfu_image_factory_build (GFile *file, * 0x0d => "uqcn.mbn" (Gobi 2000 only) */ if (g_ascii_strcasecmp (basename, "amss.mbn") == 0) - image_type = QFU_IMAGE_TYPE_AMSS_MODEM; + image = qfu_image_new (file, QFU_IMAGE_TYPE_AMSS_MODEM, cancellable, error); else if (g_ascii_strcasecmp (basename, "apps.mbn") == 0) - image_type = QFU_IMAGE_TYPE_AMSS_APPLICATION; + image = qfu_image_new (file, QFU_IMAGE_TYPE_AMSS_APPLICATION, cancellable, error); else if (g_ascii_strcasecmp (basename, "uqcn.mbn") == 0) - image_type = QFU_IMAGE_TYPE_AMSS_UQCN; - else - /* Note: should check validity of the image as this is the one used as - * default fallback */ - image_type = QFU_IMAGE_TYPE_CWE; + image = qfu_image_new (file, QFU_IMAGE_TYPE_AMSS_UQCN, cancellable, error); + else { + /* Try to autodetect format */ - switch (image_type) { - case QFU_IMAGE_TYPE_AMSS_MODEM: - case QFU_IMAGE_TYPE_AMSS_APPLICATION: - case QFU_IMAGE_TYPE_AMSS_UQCN: - image = qfu_image_new (file, image_type, cancellable, error); - break; - case QFU_IMAGE_TYPE_CWE: - image = qfu_image_cwe_new (file, cancellable, error); - break; - default: - g_assert_not_reached (); + /* Maybe a CWE image? */ + image = qfu_image_cwe_new (file, cancellable, &inner_error); + if (!image) { + g_debug ("[qfu-image-factory] not a CWE file: %s", inner_error->message); + g_error_free (inner_error); + + g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, + "unknown firmware image file"); + } } g_free (basename); |