[gnome-software: 1/3] odrs: Refactor fallback distro name code




commit dd0fd698a5ce6d63ecaa32162ec7b6a351d7f0a7
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Mar 1 16:25:09 2021 +0000

    odrs: Refactor fallback distro name code
    
    This introduces no functional changes, but eliminates duplication of a
    string which I’m about to make translatable.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1158

 plugins/odrs/gs-plugin-odrs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index 5920c4e40..fe9d12b12 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -148,15 +148,16 @@ gs_plugin_initialize (GsPlugin *plugin)
        os_release = gs_os_release_new (&error);
        if (os_release != NULL) {
                priv->distro = g_strdup (gs_os_release_get_name (os_release));
-               if (priv->distro == NULL) {
+               if (priv->distro == NULL)
                        g_warning ("no distro name specified");
-                       priv->distro = g_strdup ("Unknown");
-               }
        } else {
                g_warning ("failed to get distro name: %s", error->message);
-               priv->distro = g_strdup ("Unknown");
        }
 
+       /* Fallback */
+       if (priv->distro == NULL)
+               priv->distro = g_strdup ("Unknown");
+
        /* add source */
        priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
        gs_app_set_kind (priv->cached_origin, AS_COMPONENT_KIND_REPOSITORY);


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