From 34af790e87fdfb9e7340b4b6591104945b4e632d Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 9 Feb 2015 21:05:57 +0000 Subject: 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 6724e979..f65ebb29 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 ("
", entry->id); diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c index 710fbc62..3ec60080 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 111941bd..77e5b51a 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 a3f97a62..eb2fcb40 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 596006e0..21b07d3d 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 e139c1ab..8d155615 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
", 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 0a821195..c4c95325 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; -- cgit v1.2.1