mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01: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:
parent
9cbfb56061
commit
22cd18500d
@ -204,7 +204,7 @@ name_lookup (GDBusDaemon *daemon, const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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);
|
gsize len = strlen (value);
|
||||||
|
|
||||||
@ -1463,7 +1463,7 @@ filter_function (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
Client *client = 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)
|
if (0)
|
||||||
g_printerr ("%s%s %s %d(%d) sender: %s destination: %s %s %s.%s\n",
|
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_created;
|
||||||
gint monitor_deleted;
|
gint monitor_deleted;
|
||||||
gint monitor_changed;
|
gint monitor_changed;
|
||||||
gchar *monitor_path;
|
const gchar *monitor_path;
|
||||||
gint pos;
|
gint pos;
|
||||||
gchar *data;
|
const gchar *data;
|
||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
guint timeout;
|
guint timeout;
|
||||||
} CreateDeleteData;
|
} CreateDeleteData;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
static void
|
static void
|
||||||
test_exact (void)
|
test_exact (void)
|
||||||
{
|
{
|
||||||
char *exact_matches[] = {
|
const char *exact_matches[] = {
|
||||||
"*",
|
"*",
|
||||||
"a::*",
|
"a::*",
|
||||||
"a::*,b::*",
|
"a::*,b::*",
|
||||||
@ -29,8 +29,8 @@ static void
|
|||||||
test_equality (void)
|
test_equality (void)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
char *expected;
|
const char *expected;
|
||||||
char *actual;
|
const char *actual;
|
||||||
} equals[] = {
|
} equals[] = {
|
||||||
/* star makes everything else go away */
|
/* star makes everything else go away */
|
||||||
{ "*", "*,*" },
|
{ "*", "*,*" },
|
||||||
@ -70,9 +70,9 @@ static void
|
|||||||
test_subtract (void)
|
test_subtract (void)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
char *attributes;
|
const char *attributes;
|
||||||
char *subtract;
|
const char *subtract;
|
||||||
char *result;
|
const char *result;
|
||||||
} subtractions[] = {
|
} subtractions[] = {
|
||||||
/* * subtracts everything */
|
/* * subtracts everything */
|
||||||
{ "*", "*", NULL },
|
{ "*", "*", NULL },
|
||||||
|
@ -22,17 +22,17 @@ test_schema_do_compile (gpointer data)
|
|||||||
SchemaTest *test = (SchemaTest *) data;
|
SchemaTest *test = (SchemaTest *) data;
|
||||||
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
||||||
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
|
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
|
||||||
gchar *argv[] = {
|
const gchar *argv[] = {
|
||||||
GLIB_COMPILE_SCHEMAS,
|
GLIB_COMPILE_SCHEMAS,
|
||||||
"--strict",
|
"--strict",
|
||||||
"--dry-run",
|
"--dry-run",
|
||||||
"--schema-file", path,
|
"--schema-file", path,
|
||||||
(gchar *)test->opt,
|
test->opt,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
gchar *envp[] = { NULL };
|
gchar *envp[] = { NULL };
|
||||||
|
|
||||||
execve (argv[0], argv, envp);
|
execve (argv[0], (char **) argv, envp);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ check_source_readability_callback (gpointer user_data)
|
|||||||
static gboolean
|
static gboolean
|
||||||
write_callback (gpointer user_data)
|
write_callback (gpointer user_data)
|
||||||
{
|
{
|
||||||
char *buf = "x";
|
const char *buf = "x";
|
||||||
gssize nwrote;
|
gssize nwrote;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ static void
|
|||||||
test_uris (void)
|
test_uris (void)
|
||||||
{
|
{
|
||||||
GProxyResolver *resolver;
|
GProxyResolver *resolver;
|
||||||
gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
|
const gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
|
||||||
gchar **proxies;
|
gchar **proxies;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const gchar *uri;
|
const gchar *uri;
|
||||||
@ -41,7 +41,7 @@ test_uris (void)
|
|||||||
|
|
||||||
/* Valid URI. */
|
/* Valid URI. */
|
||||||
uri = "http://%E0%B4%A8%E0%B4%B2:80/";
|
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);
|
proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -60,7 +60,7 @@ test_uris (void)
|
|||||||
/* Invalid URI. */
|
/* Invalid URI. */
|
||||||
uri = "%E0%B4%A8%E0%B4%B2";
|
uri = "%E0%B4%A8%E0%B4%B2";
|
||||||
str = g_strdup_printf ("Invalid URI ‘%s’", uri);
|
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);
|
proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
||||||
@ -81,7 +81,7 @@ test_uris (void)
|
|||||||
g_object_unref (resolver);
|
g_object_unref (resolver);
|
||||||
g_free (str);
|
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),
|
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
|
||||||
"http", "http://proxy.example.com");
|
"http", "http://proxy.example.com");
|
||||||
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
|
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
|
||||||
@ -136,11 +136,11 @@ static void
|
|||||||
test_socks (void)
|
test_socks (void)
|
||||||
{
|
{
|
||||||
GProxyResolver *resolver;
|
GProxyResolver *resolver;
|
||||||
gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
|
const gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
|
||||||
gchar **proxies;
|
gchar **proxies;
|
||||||
GError *error = NULL;
|
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/",
|
proxies = g_proxy_resolver_lookup (resolver, "http://one.example.com/",
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
@ -160,7 +160,7 @@ test_socks (void)
|
|||||||
|
|
||||||
g_object_unref (resolver);
|
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),
|
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
|
||||||
"http", "socks://proxy.example.com");
|
"http", "socks://proxy.example.com");
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ g_on_error_stack_trace (const gchar *prg_name)
|
|||||||
#if defined(G_OS_UNIX)
|
#if defined(G_OS_UNIX)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
gchar buf[16];
|
gchar buf[16];
|
||||||
gchar *args[4] = { "gdb", NULL, NULL, NULL };
|
const gchar *args[4] = { "gdb", NULL, NULL, NULL };
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (!prg_name)
|
if (!prg_name)
|
||||||
@ -234,7 +234,7 @@ g_on_error_stack_trace (const gchar *prg_name)
|
|||||||
|
|
||||||
_g_sprintf (buf, "%u", (guint) getpid ());
|
_g_sprintf (buf, "%u", (guint) getpid ());
|
||||||
|
|
||||||
args[1] = (gchar*) prg_name;
|
args[1] = prg_name;
|
||||||
args[2] = buf;
|
args[2] = buf;
|
||||||
|
|
||||||
pid = fork ();
|
pid = fork ();
|
||||||
|
@ -235,8 +235,8 @@ g_get_codeset (void)
|
|||||||
|
|
||||||
/* read an alias file for the locales */
|
/* read an alias file for the locales */
|
||||||
static void
|
static void
|
||||||
read_aliases (gchar *file,
|
read_aliases (const gchar *file,
|
||||||
GHashTable *alias_table)
|
GHashTable *alias_table)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -2767,11 +2767,11 @@ format_z (GString *outstr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
format_number (GString *str,
|
format_number (GString *str,
|
||||||
gboolean use_alt_digits,
|
gboolean use_alt_digits,
|
||||||
gchar *pad,
|
const gchar *pad,
|
||||||
gint width,
|
gint width,
|
||||||
guint32 number)
|
guint32 number)
|
||||||
{
|
{
|
||||||
const gchar *ascii_digits[10] = {
|
const gchar *ascii_digits[10] = {
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||||
@ -2909,7 +2909,7 @@ g_date_time_format_locale (GDateTime *datetime,
|
|||||||
gunichar c;
|
gunichar c;
|
||||||
gboolean alt_digits = FALSE;
|
gboolean alt_digits = FALSE;
|
||||||
gboolean pad_set = FALSE;
|
gboolean pad_set = FALSE;
|
||||||
gchar *pad = "";
|
const gchar *pad = "";
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
const gchar *tz;
|
const gchar *tz;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
static void
|
static void
|
||||||
test_iconv_state (void)
|
test_iconv_state (void)
|
||||||
{
|
{
|
||||||
gchar *in = "\xf4\xe5\xf8\xe5\xed";
|
const gchar *in = "\xf4\xe5\xf8\xe5\xed";
|
||||||
gchar *expected = "\xd7\xa4\xd7\x95\xd7\xa8\xd7\x95\xd7\x9d";
|
const gchar *expected = "\xd7\xa4\xd7\x95\xd7\xa8\xd7\x95\xd7\x9d";
|
||||||
gchar *out;
|
gchar *out;
|
||||||
gsize bytes_read = 0;
|
gsize bytes_read = 0;
|
||||||
gsize bytes_written = 0;
|
gsize bytes_written = 0;
|
||||||
@ -107,7 +107,7 @@ test_byte_order (void)
|
|||||||
{
|
{
|
||||||
gchar in_be[4] = { 0xfe, 0xff, 0x03, 0x93}; /* capital gamma */
|
gchar in_be[4] = { 0xfe, 0xff, 0x03, 0x93}; /* capital gamma */
|
||||||
gchar in_le[4] = { 0xff, 0xfe, 0x93, 0x03};
|
gchar in_le[4] = { 0xff, 0xfe, 0x93, 0x03};
|
||||||
gchar *expected = "\xce\x93";
|
const gchar *expected = "\xce\x93";
|
||||||
gchar *out;
|
gchar *out;
|
||||||
gsize bytes_read = 0;
|
gsize bytes_read = 0;
|
||||||
gsize bytes_written = 0;
|
gsize bytes_written = 0;
|
||||||
@ -588,7 +588,7 @@ check_utf16_to_ucs4 (const gunichar2 *utf16,
|
|||||||
static void
|
static void
|
||||||
test_unicode_conversions (void)
|
test_unicode_conversions (void)
|
||||||
{
|
{
|
||||||
char *utf8;
|
const char *utf8;
|
||||||
gunichar ucs4[100];
|
gunichar ucs4[100];
|
||||||
gunichar2 utf16[100];
|
gunichar2 utf16[100];
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ test_filename_from_utf8_embedded_nul_iconv (void)
|
|||||||
static void
|
static void
|
||||||
test_no_conv (void)
|
test_no_conv (void)
|
||||||
{
|
{
|
||||||
gchar *in = "";
|
const gchar *in = "";
|
||||||
gchar *out G_GNUC_UNUSED;
|
gchar *out G_GNUC_UNUSED;
|
||||||
gsize bytes_read = 0;
|
gsize bytes_read = 0;
|
||||||
gsize bytes_written = 0;
|
gsize bytes_written = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user