Fix various const-correctness issues

Spotted when temporarily compiling with -Wwrite-strings. This only goes
a small way towards making the code base -Wwrite-strings–clean. It
introduces no functional changes, and fixes no bugs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
This commit is contained in:
Philip Withnall
2018-04-26 15:16:45 +01:00
parent 9cbfb56061
commit 22cd18500d
10 changed files with 36 additions and 36 deletions

View File

@@ -204,7 +204,7 @@ name_lookup (GDBusDaemon *daemon, const char *str)
}
static gboolean
is_key (const char *key_start, const char *key_end, char *value)
is_key (const char *key_start, const char *key_end, const char *value)
{
gsize len = strlen (value);
@@ -1463,7 +1463,7 @@ filter_function (GDBusConnection *connection,
gpointer user_data)
{
Client *client = user_data;
char *types[] = {"invalid", "method_call", "method_return", "error", "signal" };
const char *types[] = {"invalid", "method_call", "method_return", "error", "signal" };
if (0)
g_printerr ("%s%s %s %d(%d) sender: %s destination: %s %s %s.%s\n",

View File

@@ -153,9 +153,9 @@ typedef struct
gint monitor_created;
gint monitor_deleted;
gint monitor_changed;
gchar *monitor_path;
const gchar *monitor_path;
gint pos;
gchar *data;
const gchar *data;
gchar *buffer;
guint timeout;
} CreateDeleteData;

View File

@@ -3,7 +3,7 @@
static void
test_exact (void)
{
char *exact_matches[] = {
const char *exact_matches[] = {
"*",
"a::*",
"a::*,b::*",
@@ -29,8 +29,8 @@ static void
test_equality (void)
{
struct {
char *expected;
char *actual;
const char *expected;
const char *actual;
} equals[] = {
/* star makes everything else go away */
{ "*", "*,*" },
@@ -70,9 +70,9 @@ static void
test_subtract (void)
{
struct {
char *attributes;
char *subtract;
char *result;
const char *attributes;
const char *subtract;
const char *result;
} subtractions[] = {
/* * subtracts everything */
{ "*", "*", NULL },

View File

@@ -22,17 +22,17 @@ test_schema_do_compile (gpointer data)
SchemaTest *test = (SchemaTest *) data;
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
gchar *argv[] = {
const gchar *argv[] = {
GLIB_COMPILE_SCHEMAS,
"--strict",
"--dry-run",
"--schema-file", path,
(gchar *)test->opt,
test->opt,
NULL
};
gchar *envp[] = { NULL };
execve (argv[0], argv, envp);
execve (argv[0], (char **) argv, envp);
g_assert_not_reached ();
}

View File

@@ -61,7 +61,7 @@ check_source_readability_callback (gpointer user_data)
static gboolean
write_callback (gpointer user_data)
{
char *buf = "x";
const char *buf = "x";
gssize nwrote;
GError *error = NULL;

View File

@@ -32,7 +32,7 @@ static void
test_uris (void)
{
GProxyResolver *resolver;
gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
const gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
gchar **proxies;
GError *error = NULL;
const gchar *uri;
@@ -41,7 +41,7 @@ test_uris (void)
/* Valid URI. */
uri = "http://%E0%B4%A8%E0%B4%B2:80/";
resolver = g_simple_proxy_resolver_new (NULL, ignore_hosts);
resolver = g_simple_proxy_resolver_new (NULL, (char **) ignore_hosts);
proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
g_assert_no_error (error);
@@ -60,7 +60,7 @@ test_uris (void)
/* Invalid URI. */
uri = "%E0%B4%A8%E0%B4%B2";
str = g_strdup_printf ("Invalid URI %s", uri);
resolver = g_simple_proxy_resolver_new (NULL, ignore_hosts);
resolver = g_simple_proxy_resolver_new (NULL, (char **) ignore_hosts);
proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
@@ -81,7 +81,7 @@ test_uris (void)
g_object_unref (resolver);
g_free (str);
resolver = g_simple_proxy_resolver_new ("default://", ignore_hosts);
resolver = g_simple_proxy_resolver_new ("default://", (char **) ignore_hosts);
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
"http", "http://proxy.example.com");
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
@@ -136,11 +136,11 @@ static void
test_socks (void)
{
GProxyResolver *resolver;
gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
const gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
gchar **proxies;
GError *error = NULL;
resolver = g_simple_proxy_resolver_new ("socks://proxy.example.com", ignore_hosts);
resolver = g_simple_proxy_resolver_new ("socks://proxy.example.com", (char **) ignore_hosts);
proxies = g_proxy_resolver_lookup (resolver, "http://one.example.com/",
NULL, &error);
@@ -160,7 +160,7 @@ test_socks (void)
g_object_unref (resolver);
resolver = g_simple_proxy_resolver_new ("default-proxy://", ignore_hosts);
resolver = g_simple_proxy_resolver_new ("default-proxy://", (char **) ignore_hosts);
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
"http", "socks://proxy.example.com");