Commit 7c7d30fb authored by Ting-Wei Lan's avatar Ting-Wei Lan
Browse files

build: Fix build with clang -Werror and -Wwrite-strings

String literals are 'const char[]' when -Wwrite-strings is used.

https://bugzilla.gnome.org/show_bug.cgi?id=759200
parent 4342778e
......@@ -32,10 +32,10 @@
typedef struct
{
char *schema;
char *key;
char *webkit_pref;
void (*callback) (GSettings *settings, char *key, gpointer data);
const char *schema;
const char *key;
const char *webkit_pref;
void (*callback) (GSettings *settings, const char *key, gpointer data);
} PrefData;
#define ENABLE_SCRIPTS_SETTING "enable-javascript"
......@@ -88,7 +88,7 @@ user_style_seet_read_cb (GFile *file,
static void
webkit_pref_callback_user_stylesheet (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
gboolean value;
......@@ -179,7 +179,7 @@ webkit_pref_get_internal_user_agent (void)
static void
webkit_pref_callback_user_agent (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
char *value;
......@@ -235,7 +235,7 @@ normalize_font_size (gdouble font_size)
static void
webkit_pref_callback_font_size (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
char *webkit_pref = data;
......@@ -273,7 +273,7 @@ webkit_pref_callback_font_size (GSettings *settings,
static void
webkit_pref_callback_font_family (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
char *webkit_pref = data;
......@@ -337,7 +337,7 @@ normalize_languages (char **languages)
(old transform_accept_languages_list() function) */
static void
webkit_pref_callback_accept_languages (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
GArray *array;
......@@ -396,7 +396,7 @@ ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
static void
webkit_pref_callback_cookie_accept_policy (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
WebKitCookieManager *cookie_manager;
......@@ -414,7 +414,7 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings,
}
static void
ephy_embed_prefs_update_font_settings (GSettings *ephy_settings, char *key)
ephy_embed_prefs_update_font_settings (GSettings *ephy_settings, const char *key)
{
if (g_settings_get_boolean (ephy_settings, key)) {
g_object_set (webkit_settings,
......@@ -427,24 +427,24 @@ ephy_embed_prefs_update_font_settings (GSettings *ephy_settings, char *key)
} else {
/* Sync with Epiphany values */
webkit_pref_callback_font_size (ephy_settings, EPHY_PREFS_WEB_SERIF_FONT,
"default-font-size");
(gpointer)"default-font-size");
webkit_pref_callback_font_size (ephy_settings, EPHY_PREFS_WEB_MONOSPACE_FONT,
"default-monospace-font-size");
(gpointer)"default-monospace-font-size");
webkit_pref_callback_font_family (ephy_settings, EPHY_PREFS_WEB_SERIF_FONT,
"default-font-family");
(gpointer)"default-font-family");
webkit_pref_callback_font_family (ephy_settings, EPHY_PREFS_WEB_SANS_SERIF_FONT,
"sans-serif-font-family");
(gpointer)"sans-serif-font-family");
webkit_pref_callback_font_family (ephy_settings, EPHY_PREFS_WEB_MONOSPACE_FONT,
"monospace-font-family");
(gpointer)"monospace-font-family");
webkit_pref_callback_font_family (ephy_settings, EPHY_PREFS_WEB_SERIF_FONT,
"serif-font-family");
(gpointer)"serif-font-family");
}
}
static void
webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
char *key,
const char *key,
gpointer data)
{
ephy_embed_prefs_update_font_settings (ephy_settings, key);
......@@ -452,7 +452,7 @@ webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
static void
webkit_pref_callback_enable_spell_checking (GSettings *settings,
char *key,
const char *key,
gpointer data)
{
WebKitWebContext *web_context;
......@@ -562,11 +562,11 @@ ephy_embed_prefs_init (gpointer user_data)
webkit_pref_entries[i].callback (settings,
webkit_pref_entries[i].key,
webkit_pref_entries[i].webkit_pref);
(gpointer)webkit_pref_entries[i].webkit_pref);
g_signal_connect (settings, key,
G_CALLBACK (webkit_pref_entries[i].callback),
webkit_pref_entries[i].webkit_pref);
(gpointer)webkit_pref_entries[i].webkit_pref);
g_free (key);
}
......
......@@ -51,8 +51,8 @@ static guint signals[LAST_SIGNAL];
static const
struct
{
char *title;
char *code;
const char *title;
const char *code;
EphyLanguageGroup groups;
}
encoding_entries [] =
......
......@@ -442,7 +442,7 @@ ephy_uri_tester_fixup_regexp (const char *prefix, char *src)
static void
ephy_uri_tester_compile_regexp (EphyUriTester *tester,
GString *gpatt,
char *opts,
const char *opts,
gboolean whitelist)
{
GHashTable *pattern;
......@@ -481,15 +481,15 @@ ephy_uri_tester_compile_regexp (EphyUriTester *tester,
static void
ephy_uri_tester_add_url_pattern (EphyUriTester *tester,
char *prefix,
char *type,
const char *prefix,
const char *type,
char *line,
gboolean whitelist)
{
char **data;
char *patt;
GString *format_patt;
char *opts;
const char *opts;
data = g_strsplit (line, "$", -1);
if (!data || !data[0])
......@@ -519,7 +519,7 @@ ephy_uri_tester_add_url_pattern (EphyUriTester *tester,
if (data[1] && data[2])
g_free (patt);
if (data[1])
g_free (opts);
g_free ((char *)opts);
g_strfreev (data);
return;
}
......@@ -536,7 +536,7 @@ ephy_uri_tester_add_url_pattern (EphyUriTester *tester,
if (data[1] && data[2])
g_free (patt);
if (data[1])
g_free (opts);
g_free ((char *)opts);
g_strfreev (data);
g_string_free (format_patt, TRUE);
......
......@@ -360,7 +360,7 @@ ephy_file_helpers_init (const char *profile_dir,
if (steal_data_from_profile && profile_dir)
{
int i;
char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
const char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++)
{
......
......@@ -93,7 +93,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
GError *error = NULL;
char *index = NULL, *version = NULL;
int status;
char *argv[6] = { EPHY_PROFILE_MIGRATOR, "-v" };
const char *argv[6] = { EPHY_PROFILE_MIGRATOR, "-v" };
int i = 2; /* index for argv, start filling at 2. */
char **envp;
......@@ -128,7 +128,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
if (debug)
argv[0] = ABS_TOP_BUILD_DIR"/lib/"EPHY_PROFILE_MIGRATOR;
ret = g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH,
ret = g_spawn_sync (NULL, (char **)argv, envp, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL,
&status, &error);
g_free (index);
......
......@@ -35,7 +35,7 @@ G_BEGIN_DECLS
static const
struct
{
gchar *name;
const gchar *name;
float level;
}
zoom_levels[] =
......
......@@ -86,9 +86,9 @@ struct _EphyLocationEntryPrivate
static const GtkTargetEntry url_drag_types [] =
{
{ EPHY_DND_URL_TYPE, 0, 0 },
{ EPHY_DND_URI_LIST_TYPE, 0, 1 },
{ EPHY_DND_TEXT_TYPE, 0, 2 }
{ (char *)EPHY_DND_URL_TYPE, 0, 0 },
{ (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
{ (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *, gboolean);
......
......@@ -48,19 +48,19 @@
static const GtkTargetEntry topic_drag_dest_types [] =
{
{ EPHY_DND_URI_LIST_TYPE, 0, 0 }
{ (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 }
};
static const GtkTargetEntry bmk_drag_types [] =
{
{ EPHY_DND_URL_TYPE, 0, 0 },
{ EPHY_DND_URI_LIST_TYPE, 0, 1 },
{ EPHY_DND_TEXT_TYPE, 0, 2 }
{ (char *)EPHY_DND_URL_TYPE, 0, 0 },
{ (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
{ (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static const GtkTargetEntry topic_drag_types [] =
{
{ EPHY_DND_TOPIC_TYPE, 0, 0 }
{ (char *)EPHY_DND_TOPIC_TYPE, 0, 0 }
};
static const struct
......
......@@ -326,7 +326,7 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, GList *folders)
for (l = folders; l != NULL; l=l->next)
{
char *title;
const char *title;
title = l->data ? (char *) l->data : "";
......@@ -824,7 +824,7 @@ parse_rdf_lang_tag (xmlNode *child,
int *best_match)
{
const char * const *locales;
char *this_language;
const char *this_language;
xmlChar *lang;
xmlChar *content;
int i;
......
......@@ -37,7 +37,7 @@ ephy_home_action_open (GtkAction *action,
static void
action_name_association (GtkAction *action,
char *action_name,
char *address)
const char *address)
{
EphyLinkFlags flags = EPHY_LINK_HOME_PAGE;
......
......@@ -56,7 +56,7 @@ find_action_group (GtkUIManager *manager,
static void
arbitrary_url_cb (GSettings *settings,
char *key,
const char *key,
EphyWindow *window)
{
EphyEmbed *embed;
......@@ -77,7 +77,7 @@ arbitrary_url_cb (GSettings *settings,
static void
fullscreen_cb (GSettings *settings,
char *key,
const char *key,
EphyWindow *window)
{
if (g_settings_get_boolean (settings, key))
......@@ -87,9 +87,9 @@ fullscreen_cb (GSettings *settings,
}
typedef struct {
char *key;
char *action;
char *prop;
const char *key;
const char *action;
const char *prop;
} BindAction;
static const BindAction window_actions[] = {
......
......@@ -147,7 +147,7 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
XSetWindowAttributes attrs;
Atom atom_name;
Atom atom_type;
char* name;
const char* name;
attrs.override_redirect = True;
attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
......
......@@ -65,9 +65,9 @@ static void ephy_notebook_remove (GtkContainer *container,
static const GtkTargetEntry url_drag_types [] =
{
{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
{ EPHY_DND_URI_LIST_TYPE, 0, 0 },
{ EPHY_DND_URL_TYPE, 0, 1 },
{ (char *)"GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
{ (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 },
{ (char *)EPHY_DND_URL_TYPE, 0, 1 },
};
enum
......
......@@ -369,7 +369,7 @@ perform_complex_url_query (EphyHistoryService *service,
/* Get the most visited site that contains 'k'. */
query = ephy_history_query_new ();
query->substring_list = g_list_prepend (query->substring_list, "k");
query->substring_list = g_list_prepend (query->substring_list, (gpointer)"k");
query->limit = 1;
query->sort_type = EPHY_HISTORY_SORT_MOST_VISITED;
......@@ -408,7 +408,7 @@ perform_complex_url_query_with_time_range (EphyHistoryService *service,
/* Get the most visited site that contains 'k' that was visited since timestamp 500. */
query = ephy_history_query_new ();
query->substring_list = g_list_prepend (query->substring_list, "k");
query->substring_list = g_list_prepend (query->substring_list, (gpointer)"k");
query->limit = 1;
query->sort_type = EPHY_HISTORY_SORT_MOST_VISITED;
query->from = 500;
......@@ -463,7 +463,7 @@ perform_query_after_clear (EphyHistoryService *service,
/* Get 10 random sites, the query should fail. */
query = ephy_history_query_new ();
query->substring_list = g_list_prepend (query->substring_list, "gnome");
query->substring_list = g_list_prepend (query->substring_list, (gpointer)"gnome");
query->limit = 10;
query->sort_type = EPHY_HISTORY_SORT_MOST_VISITED;
......
......@@ -23,8 +23,8 @@
#include <gtk/gtk.h>
typedef struct {
char *uri;
char *hostname;
const char *uri;
const char *hostname;
} HostnameTest;
static const HostnameTest hostname_tests[] = {
......
......@@ -245,8 +245,8 @@ test_ephy_web_view_non_search_regex (void)
}
typedef struct {
char *url;
char *expected;
const char *url;
const char *expected;
} normalize_or_autosearch_t;
normalize_or_autosearch_t normalize_or_autosearch_test_ddg[] = {
......@@ -278,7 +278,8 @@ verify_normalize_or_autosearch_urls (EphyWebView *view,
int i;
for (i = 0; i < n_tests; i++) {
char *url, *result;
const char *url;
char *result;
url = test[i].url;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment