[gnome-software/gnome-42: 1/4] appstream: Don’t check for G_IO_ERROR_INVALID_ARGUMENT from libxmlb




commit e585f110c38181ab7f71eec281f47803562a338f
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed May 25 11:58:48 2022 +0100

    appstream: Don’t check for G_IO_ERROR_INVALID_ARGUMENT from libxmlb
    
    It shouldn’t really ever be returned, unless there’s been a programmer
    error by passing an invalid query.
    
    This error check has been cargo-culted throughout the gnome-software
    code and should be removed pretty much everywhere.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-appstream.c                 | 40 +-------------------------------------
 plugins/core/gs-plugin-appstream.c |  8 --------
 plugins/flatpak/gs-flatpak.c       |  2 --
 3 files changed, 1 insertion(+), 49 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 1908e5eef..cb07cab9b 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -358,8 +358,6 @@ gs_appstream_refine_add_addons (GsPlugin *plugin,
        if (addons == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -385,8 +383,6 @@ gs_appstream_refine_add_images (GsApp *app, AsScreenshot *ss, XbNode *screenshot
        if (images == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -415,8 +411,6 @@ gs_appstream_refine_add_screenshots (GsApp *app, XbNode *component, GError **err
        if (screenshots == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -447,8 +441,6 @@ gs_appstream_refine_add_provides (GsApp *app, XbNode *component, GError **error)
        if (provides == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -552,8 +544,6 @@ gs_appstream_copy_metadata (GsApp *app, XbNode *component, GError **error)
        if (values == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -592,8 +582,7 @@ gs_appstream_refine_app_updates (GsApp *app,
                                 gs_app_get_id (app));
        releases_inst = xb_silo_query (silo, xpath, 0, &error_local);
        if (releases_inst == NULL) {
-               if (!g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
-                   !g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT)) {
+               if (!g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
                        g_propagate_error (error, g_steal_pointer (&error_local));
                        return FALSE;
                }
@@ -612,8 +601,6 @@ gs_appstream_refine_app_updates (GsApp *app,
        if (releases == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -713,8 +700,6 @@ gs_appstream_refine_add_version_history (GsApp *app, XbNode *component, GError *
        if (releases == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -835,9 +820,6 @@ gs_appstream_refine_app_content_rating (GsApp *app,
        if (content_attributes == NULL &&
            g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
                g_clear_error (&error_local);
-       } else if (content_attributes == NULL &&
-                g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT)) {
-               return TRUE;
        } else if (content_attributes == NULL) {
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
@@ -867,8 +849,6 @@ gs_appstream_refine_app_content_ratings (GsApp *app,
        if (content_ratings == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -945,8 +925,6 @@ gs_appstream_refine_app_relations (GsApp     *app,
        if (recommends == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -962,8 +940,6 @@ gs_appstream_refine_app_relations (GsApp     *app,
        if (requires == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1454,8 +1430,6 @@ gs_appstream_search (GsPlugin *plugin,
        if (components == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1540,8 +1514,6 @@ gs_appstream_add_category_apps (GsPlugin *plugin,
                if (components == NULL) {
                        if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                                return TRUE;
-                       if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                               return TRUE;
                        g_propagate_error (error, g_steal_pointer (&error_local));
                        return FALSE;
                }
@@ -1591,8 +1563,6 @@ gs_appstream_count_component_for_groups (XbSilo      *silo,
        if (array == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return 0;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return 0;
                g_warning ("%s", error_local->message);
                return 0;
        }
@@ -1649,8 +1619,6 @@ gs_appstream_add_popular (XbSilo *silo,
        if (array == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1688,8 +1656,6 @@ gs_appstream_add_recent (GsPlugin *plugin,
        if (array == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1750,8 +1716,6 @@ gs_appstream_add_alternates (XbSilo *silo,
        if (ids == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1787,8 +1751,6 @@ gs_appstream_add_featured (XbSilo *silo,
        if (array == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index f56352960..829b11174 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -1057,8 +1057,6 @@ gs_plugin_appstream_refine_state (GsPluginAppstream  *self,
        if (component == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1101,8 +1099,6 @@ gs_plugin_refine_from_id (GsPluginAppstream    *self,
        if (components == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
@@ -1156,8 +1152,6 @@ gs_plugin_refine_from_pkgname (GsPluginAppstream    *self,
                if (component == NULL) {
                        if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                                continue;
-                       if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                               continue;
                        g_propagate_error (error, g_steal_pointer (&error_local));
                        return FALSE;
                }
@@ -1310,8 +1304,6 @@ refine_wildcard (GsPluginAppstream    *self,
        if (components == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 1bb3b65a9..e22eac4d0 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3400,8 +3400,6 @@ gs_flatpak_refine_wildcard (GsFlatpak *self, GsApp *app,
        if (components == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
-               if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
-                       return TRUE;
                g_propagate_error (error, g_steal_pointer (&error_local));
                return FALSE;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]