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
|
||||
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");
|
||||
|
||||
|
@ -226,7 +226,7 @@ g_on_error_stack_trace (const gchar *prg_name)
|
||||
#if defined(G_OS_UNIX)
|
||||
pid_t pid;
|
||||
gchar buf[16];
|
||||
gchar *args[4] = { "gdb", NULL, NULL, NULL };
|
||||
const gchar *args[4] = { "gdb", NULL, NULL, NULL };
|
||||
int status;
|
||||
|
||||
if (!prg_name)
|
||||
@ -234,7 +234,7 @@ g_on_error_stack_trace (const gchar *prg_name)
|
||||
|
||||
_g_sprintf (buf, "%u", (guint) getpid ());
|
||||
|
||||
args[1] = (gchar*) prg_name;
|
||||
args[1] = prg_name;
|
||||
args[2] = buf;
|
||||
|
||||
pid = fork ();
|
||||
|
@ -235,7 +235,7 @@ g_get_codeset (void)
|
||||
|
||||
/* read an alias file for the locales */
|
||||
static void
|
||||
read_aliases (gchar *file,
|
||||
read_aliases (const gchar *file,
|
||||
GHashTable *alias_table)
|
||||
{
|
||||
FILE *fp;
|
||||
|
@ -2769,7 +2769,7 @@ format_z (GString *outstr,
|
||||
static void
|
||||
format_number (GString *str,
|
||||
gboolean use_alt_digits,
|
||||
gchar *pad,
|
||||
const gchar *pad,
|
||||
gint width,
|
||||
guint32 number)
|
||||
{
|
||||
@ -2909,7 +2909,7 @@ g_date_time_format_locale (GDateTime *datetime,
|
||||
gunichar c;
|
||||
gboolean alt_digits = FALSE;
|
||||
gboolean pad_set = FALSE;
|
||||
gchar *pad = "";
|
||||
const gchar *pad = "";
|
||||
const gchar *name;
|
||||
const gchar *tz;
|
||||
|
||||
|
@ -34,8 +34,8 @@
|
||||
static void
|
||||
test_iconv_state (void)
|
||||
{
|
||||
gchar *in = "\xf4\xe5\xf8\xe5\xed";
|
||||
gchar *expected = "\xd7\xa4\xd7\x95\xd7\xa8\xd7\x95\xd7\x9d";
|
||||
const gchar *in = "\xf4\xe5\xf8\xe5\xed";
|
||||
const gchar *expected = "\xd7\xa4\xd7\x95\xd7\xa8\xd7\x95\xd7\x9d";
|
||||
gchar *out;
|
||||
gsize bytes_read = 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_le[4] = { 0xff, 0xfe, 0x93, 0x03};
|
||||
gchar *expected = "\xce\x93";
|
||||
const gchar *expected = "\xce\x93";
|
||||
gchar *out;
|
||||
gsize bytes_read = 0;
|
||||
gsize bytes_written = 0;
|
||||
@ -588,7 +588,7 @@ check_utf16_to_ucs4 (const gunichar2 *utf16,
|
||||
static void
|
||||
test_unicode_conversions (void)
|
||||
{
|
||||
char *utf8;
|
||||
const char *utf8;
|
||||
gunichar ucs4[100];
|
||||
gunichar2 utf16[100];
|
||||
|
||||
@ -913,7 +913,7 @@ test_filename_from_utf8_embedded_nul_iconv (void)
|
||||
static void
|
||||
test_no_conv (void)
|
||||
{
|
||||
gchar *in = "";
|
||||
const gchar *in = "";
|
||||
gchar *out G_GNUC_UNUSED;
|
||||
gsize bytes_read = 0;
|
||||
gsize bytes_written = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user