[gnome-software] trivial: Use g_strdup_printf



commit 8f1aa7c69fda5153e5441b7655fd403cd448f328
Author: Kalev Lember <klember redhat com>
Date:   Fri Nov 10 14:16:00 2017 +0100

    trivial: Use g_strdup_printf
    
    This makes the code slightly easier to read.

 plugins/core/gs-plugin-desktop-categories.c |    5 ++---
 plugins/core/gs-plugin-desktop-menu-path.c  |    6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/plugins/core/gs-plugin-desktop-categories.c b/plugins/core/gs-plugin-desktop-categories.c
index 908608c..06c5427 100644
--- a/plugins/core/gs-plugin-desktop-categories.c
+++ b/plugins/core/gs-plugin-desktop-categories.c
@@ -46,13 +46,13 @@ gs_plugin_add_categories (GsPlugin *plugin,
                          GError **error)
 {
        const GsDesktopData *msdata;
-       gchar msgctxt[100];
        guint i, j, k;
 
        msdata = gs_desktop_get_data ();
        for (i = 0; msdata[i].id != NULL; i++) {
                GdkRGBA key_color;
                GsCategory *category;
+               g_autofree gchar *msgctxt = NULL;
 
                /* add parent category */
                category = gs_category_new (msdata[i].id);
@@ -62,8 +62,7 @@ gs_plugin_add_categories (GsPlugin *plugin,
                if (gdk_rgba_parse (&key_color, msdata[i].key_colors))
                        gs_category_add_key_color (category, &key_color);
                g_ptr_array_add (list, category);
-               g_snprintf (msgctxt, sizeof(msgctxt),
-                           "Menu of %s", msdata[i].name);
+               msgctxt = g_strdup_printf ("Menu of %s", msdata[i].name);
 
                /* add subcategories */
                for (j = 0; msdata[i].mapping[j].id != NULL; j++) {
diff --git a/plugins/core/gs-plugin-desktop-menu-path.c b/plugins/core/gs-plugin-desktop-menu-path.c
index 3a5247c..f8bb876 100644
--- a/plugins/core/gs-plugin-desktop-menu-path.c
+++ b/plugins/core/gs-plugin-desktop-menu-path.c
@@ -64,7 +64,6 @@ gs_plugin_refine_app (GsPlugin *plugin,
        const GsDesktopData *msdata;
        gboolean found = FALSE;
        guint i, j, k;
-       gchar msgctxt[100];
 
        /* nothing to do here */
        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH) == 0)
@@ -78,12 +77,13 @@ gs_plugin_refine_app (GsPlugin *plugin,
                const GsDesktopData *data = &msdata[i];
                for (j = 0; !found && data->mapping[j].id != NULL; j++) {
                        const GsDesktopMap *map = &data->mapping[j];
+                       g_autofree gchar *msgctxt = NULL;
+
                        if (g_strcmp0 (map->id, "all") == 0)
                                continue;
                        if (g_strcmp0 (map->id, "featured") == 0)
                                continue;
-                       g_snprintf (msgctxt, sizeof(msgctxt),
-                                   "Menu of %s", data->name);
+                       msgctxt = g_strdup_printf ("Menu of %s", data->name);
                        for (k = 0; !found && map->fdo_cats[k] != NULL; k++) {
                                const gchar *tmp = msdata[i].mapping[j].fdo_cats[k];
                                if (_gs_app_has_desktop_group (app, tmp)) {


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