[yelp] Fix warnings about discarding const



commit 34af790e87fdfb9e7340b4b6591104945b4e632d
Author: David King <amigadave amigadave com>
Date:   Mon Feb 9 21:05:57 2015 +0000

    Fix warnings about discarding const

 libyelp/yelp-help-list.c        |    2 +-
 libyelp/yelp-mallard-document.c |    2 +-
 libyelp/yelp-man-document.c     |    4 ++--
 libyelp/yelp-man-parser.c       |    8 +++++---
 libyelp/yelp-settings.c         |    2 +-
 libyelp/yelp-uri.c              |   10 ++++++----
 libyelp/yelp-view.c             |    4 ++--
 7 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/libyelp/yelp-help-list.c b/libyelp/yelp-help-list.c
index 6724e97..f65ebb2 100644
--- a/libyelp/yelp-help-list.c
+++ b/libyelp/yelp-help-list.c
@@ -560,7 +560,7 @@ help_list_handle_page (YelpHelpList *list,
     for (cur = priv->all_entries; cur != NULL; cur = cur->next) {
         HelpListEntry *entry = (HelpListEntry *) cur->data;
         gchar *title = entry->title ? entry->title : (strchr (entry->id, ':') + 1);
-        gchar *desc = entry->desc ? entry->desc : "";
+        const gchar *desc = entry->desc ? entry->desc : "";
 
         tmp = g_markup_printf_escaped ("<a href='%s'><div class='linkdiv'>",
                                        entry->id);
diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c
index 710fbc6..3ec6008 100644
--- a/libyelp/yelp-mallard-document.c
+++ b/libyelp/yelp-mallard-document.c
@@ -843,7 +843,7 @@ xml_node_get_icon (xmlNodePtr node)
 {
     xmlChar *style;
     gchar **styles;
-    gchar *icon = "yelp-page-symbolic";
+    const gchar *icon = "yelp-page-symbolic";
     style = xmlGetProp (node, BAD_CAST "style");
     if (style) {
         gint i;
diff --git a/libyelp/yelp-man-document.c b/libyelp/yelp-man-document.c
index 111941b..77e5b51 100644
--- a/libyelp/yelp-man-document.c
+++ b/libyelp/yelp-man-document.c
@@ -64,8 +64,8 @@ struct _YelpManDocumentPrivate {
 
 typedef struct _YelpLangEncodings YelpLangEncodings;
 struct _YelpLangEncodings {
-    gchar *language;
-    gchar *encoding;
+    const gchar *language;
+    const gchar *encoding;
 };
 /* http://www.w3.org/International/O-charset-lang.html */
 static const YelpLangEncodings langmap[] = {
diff --git a/libyelp/yelp-man-parser.c b/libyelp/yelp-man-parser.c
index a3f97a6..eb2fcb4 100644
--- a/libyelp/yelp-man-parser.c
+++ b/libyelp/yelp-man-parser.c
@@ -369,9 +369,8 @@ get_troff (gchar *path, GError **error)
 {
     gint ystdout;
     GError *err = NULL;
-    gchar *argv[] = { "man", "-Z", "-Tutf8", "-EUTF-8", NULL, NULL };
-
-    argv[4] = path;
+    gchar *argv[] = { g_strdup ("man"), g_strdup ("-Z"), g_strdup ("-Tutf8"),
+                      g_strdup ("-EUTF-8"), g_strdup (path), NULL };
 
     if (!g_spawn_async_with_pipes (NULL, argv, NULL,
                                    G_SPAWN_SEARCH_PATH, NULL, NULL,
@@ -380,9 +379,12 @@ get_troff (gchar *path, GError **error)
         *error = g_error_new (YELP_ERROR, YELP_ERROR_UNKNOWN,
                               "%s", err->message);
         g_error_free (err);
+        g_strfreev (argv);
         return NULL;
     }
 
+    g_strfreev (argv);
+
     return (GInputStream*) g_unix_input_stream_new (ystdout, TRUE);
 }
 
diff --git a/libyelp/yelp-settings.c b/libyelp/yelp-settings.c
index 596006e..21b07d3 100644
--- a/libyelp/yelp-settings.c
+++ b/libyelp/yelp-settings.c
@@ -71,7 +71,7 @@ enum {
   PROP_EDITOR_MODE
 };
 
-static gchar *icon_names[YELP_SETTINGS_NUM_ICONS];
+static const gchar *icon_names[YELP_SETTINGS_NUM_ICONS];
 
 G_DEFINE_TYPE (YelpSettings, yelp_settings, G_TYPE_OBJECT)
 #define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_SETTINGS, YelpSettingsPriv))
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index e139c1a..8d15561 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -917,7 +917,7 @@ resolve_help_list_uri (YelpUri *uri)
 static gchar*
 find_man_path (gchar* name, gchar* section)
 {
-    gchar* argv[] = { "man", "-w", NULL, NULL, NULL };
+    gchar* argv[] = { g_strdup ("man"), g_strdup ("-w"), NULL, NULL, NULL };
     gchar *ystdout = NULL;
     gint status;
     gchar **lines;
@@ -926,10 +926,10 @@ find_man_path (gchar* name, gchar* section)
     /* Syntax for man is "man -w <section> <name>", possibly omitting
        section */
     if (section) {
-        argv[2] = section;
-        argv[3] = name;
+        argv[2] = g_strdup (section);
+        argv[3] = g_strdup (name);
     } else {
-        argv[2] = name;
+        argv[2] = g_strdup (name);
     }
 
     if (!g_spawn_sync (NULL, argv, NULL,
@@ -941,6 +941,8 @@ find_man_path (gchar* name, gchar* section)
         g_error_free (error);
     }
 
+    g_strfreev (argv);
+
     if (status == 0) {
         lines = g_strsplit (ystdout, "\n", 2);
         g_free (ystdout);
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index 0a82119..c4c9532 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -781,7 +781,7 @@ view_install_uri (YelpView    *view,
     GtkWidget *gtkwin;
     GdkWindow *gdkwin;
     /* do not free */
-    gchar *pkg, *confirm_search;
+    const gchar *pkg, *confirm_search;
 
     if (g_str_has_prefix (uri, "install-help:")) {
         help = TRUE;
@@ -1774,7 +1774,7 @@ view_show_error_page (YelpView *view,
     if (doc404) {
         gchar *struri = yelp_uri_get_document_uri (priv->uri);
         /* do not free */
-        gchar *pkg = NULL, *scheme = NULL;
+        const gchar *pkg = NULL, *scheme = NULL;
         if (g_str_has_prefix (struri, "help:")) {
             scheme = "help";
             pkg = struri + 5;


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