From 1b50643c99ce990547f19cfecc3aa88ec8c7bdd7 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 5 Mar 2019 12:22:51 +0000 Subject: [PATCH] gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT Mostly unused variables which are only used in a g_assert() call otherwise. Signed-off-by: Philip Withnall Helps: #1708 --- gio/gapplicationimpl-dbus.c | 2 +- gio/gdatainputstream.c | 2 +- gio/gdbusmessage.c | 5 ++++- gio/gfileinfo.c | 3 ++- gio/gkeyfilesettingsbackend.c | 2 +- gio/glib-compile-schemas.c | 4 +++- gio/glocalfilemonitor.c | 2 ++ gio/gsettingsschema.c | 4 ++-- gio/gsocketconnection.c | 2 ++ gio/gsubprocess.c | 2 +- gio/inotify/ginotifyfilemonitor.c | 4 +++- 11 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 76d67eec8..fd9d0468d 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -774,7 +774,7 @@ g_application_impl_command_line (GApplicationImpl *impl, const gchar *object_path = "/org/gtk/Application/CommandLine"; GMainContext *context; CommandLineData data; - guint object_id; + guint object_id G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; context = g_main_context_new (); data.loop = g_main_loop_new (context, FALSE); diff --git a/gio/gdatainputstream.c b/gio/gdatainputstream.c index c2b19fdc9..2e7750cb5 100644 --- a/gio/gdatainputstream.c +++ b/gio/gdatainputstream.c @@ -936,7 +936,7 @@ g_data_input_stream_read_until (GDataInputStream *stream, /* If we're not at end of stream then we have a stop_char to consume. */ if (result != NULL && g_buffered_input_stream_get_available (bstream) > 0) { - gsize res; + gsize res G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; gchar b; res = g_input_stream_read (G_INPUT_STREAM (stream), &b, 1, NULL, NULL); diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index 3a1a1f9e9..9b89dc5b6 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c @@ -1714,7 +1714,7 @@ parse_value_from_blob (GMemoryBuffer *buf, if (array_len == 0) { - GVariant *item; + GVariant *item G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; item = parse_value_from_blob (buf, element_type, TRUE, @@ -2345,7 +2345,10 @@ append_value_to_blob (GVariant *value, { gsize len; const gchar *v; +#ifndef G_DISABLE_ASSERT const gchar *end; +#endif + v = g_variant_get_string (value, &len); g_assert (g_utf8_validate (v, -1, &end) && (end == v + len)); g_memory_buffer_put_uint32 (mbuf, len); diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c index 420e46d56..d1c9140df 100644 --- a/gio/gfileinfo.c +++ b/gio/gfileinfo.c @@ -179,7 +179,8 @@ ensure_attribute_hash (void) attribute_hash = g_hash_table_new (g_str_hash, g_str_equal); #define REGISTER_ATTRIBUTE(name) G_STMT_START{\ - guint _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \ + guint _u G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; \ + _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \ /* use for generating the ID: g_print ("#define G_FILE_ATTRIBUTE_ID_%s (%u + %u)\n", #name + 17, _u & ~ID_MASK, _u & ID_MASK); */ \ g_assert (_u == G_FILE_ATTRIBUTE_ID_ ## name); \ }G_STMT_END diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c index 6ffb48217..3bc392351 100644 --- a/gio/gkeyfilesettingsbackend.c +++ b/gio/gkeyfilesettingsbackend.c @@ -334,7 +334,7 @@ g_keyfile_settings_backend_write_one (gpointer key, gpointer user_data) { WriteManyData *data = user_data; - gboolean success; + gboolean success G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; success = set_to_keyfile (data->kfsb, key, value); g_assert (success); diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index 5e1bebbba..8ad3c6be1 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -648,8 +648,10 @@ key_state_serialise (KeyState *state) else { GVariantBuilder builder; + gboolean checked G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; - g_assert (key_state_check (state, NULL)); + checked = key_state_check (state, NULL); + g_assert (checked); g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c index 278d9a492..897d5f244 100644 --- a/gio/glocalfilemonitor.c +++ b/gio/glocalfilemonitor.c @@ -328,6 +328,7 @@ g_file_monitor_source_send_synthetic_created (GFileMonitorSource *fms, g_file_monitor_source_queue_event (fms, G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, child, NULL); } +#ifndef G_DISABLE_ASSERT static gboolean is_basename (const gchar *name) { @@ -336,6 +337,7 @@ is_basename (const gchar *name) return !strchr (name, '/'); } +#endif /* !G_DISABLE_ASSERT */ gboolean g_file_monitor_source_handle_event (GFileMonitorSource *fms, diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c index 60b3fe0b3..f7c50c210 100644 --- a/gio/gsettingsschema.c +++ b/gio/gsettingsschema.c @@ -1455,7 +1455,7 @@ gint g_settings_schema_key_to_enum (GSettingsSchemaKey *key, GVariant *value) { - gboolean it_worked; + gboolean it_worked G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; guint result; it_worked = strinfo_enum_from_string (key->strinfo, key->strinfo_length, @@ -1499,7 +1499,7 @@ g_settings_schema_key_to_flags (GSettingsSchemaKey *key, g_variant_iter_init (&iter, value); while (g_variant_iter_next (&iter, "&s", &flag)) { - gboolean it_worked; + gboolean it_worked G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; guint flag_value; it_worked = strinfo_enum_from_string (key->strinfo, key->strinfo_length, flag, &flag_value); diff --git a/gio/gsocketconnection.c b/gio/gsocketconnection.c index 5fab8f4f7..37d5d330c 100644 --- a/gio/gsocketconnection.c +++ b/gio/gsocketconnection.c @@ -389,7 +389,9 @@ g_socket_connection_set_property (GObject *object, static void g_socket_connection_constructed (GObject *object) { +#ifndef G_DISABLE_ASSERT GSocketConnection *connection = G_SOCKET_CONNECTION (object); +#endif g_assert (connection->priv->socket != NULL); } diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c index dcdb84d58..7630c7b45 100644 --- a/gio/gsubprocess.c +++ b/gio/gsubprocess.c @@ -575,7 +575,7 @@ initable_init (GInitable *initable, { guint64 identifier; - gint s; + gint s G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; #ifdef G_OS_WIN32 identifier = (guint64) GetProcessId (self->pid); diff --git a/gio/inotify/ginotifyfilemonitor.c b/gio/inotify/ginotifyfilemonitor.c index 4c95e87fb..b2364cc2c 100644 --- a/gio/inotify/ginotifyfilemonitor.c +++ b/gio/inotify/ginotifyfilemonitor.c @@ -55,7 +55,7 @@ g_inotify_file_monitor_start (GLocalFileMonitor *local_monitor, GFileMonitorSource *source) { GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (local_monitor); - gboolean success; + gboolean success G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */; /* should already have been called, from is_supported() */ success = _ih_startup (); @@ -83,7 +83,9 @@ g_inotify_file_monitor_cancel (GFileMonitor *monitor) static void g_inotify_file_monitor_finalize (GObject *object) { +#ifndef G_DISABLE_ASSERT GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (object); +#endif /* must surely have been cancelled already */ g_assert (!inotify_monitor->sub);