mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
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:
@@ -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",
|
||||
|
@@ -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;
|
||||
|
@@ -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 },
|
||||
|
@@ -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 ();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user