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 <withnall@endlessm.com>

Helps: #1708
This commit is contained in:
Philip Withnall 2019-03-05 12:22:51 +00:00
parent 9ce76b97f1
commit 1b50643c99
11 changed files with 22 additions and 10 deletions

View File

@ -774,7 +774,7 @@ g_application_impl_command_line (GApplicationImpl *impl,
const gchar *object_path = "/org/gtk/Application/CommandLine"; const gchar *object_path = "/org/gtk/Application/CommandLine";
GMainContext *context; GMainContext *context;
CommandLineData data; CommandLineData data;
guint object_id; guint object_id G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
context = g_main_context_new (); context = g_main_context_new ();
data.loop = g_main_loop_new (context, FALSE); data.loop = g_main_loop_new (context, FALSE);

View File

@ -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 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) 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; gchar b;
res = g_input_stream_read (G_INPUT_STREAM (stream), &b, 1, NULL, NULL); res = g_input_stream_read (G_INPUT_STREAM (stream), &b, 1, NULL, NULL);

View File

@ -1714,7 +1714,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
if (array_len == 0) if (array_len == 0)
{ {
GVariant *item; GVariant *item G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
item = parse_value_from_blob (buf, item = parse_value_from_blob (buf,
element_type, element_type,
TRUE, TRUE,
@ -2345,7 +2345,10 @@ append_value_to_blob (GVariant *value,
{ {
gsize len; gsize len;
const gchar *v; const gchar *v;
#ifndef G_DISABLE_ASSERT
const gchar *end; const gchar *end;
#endif
v = g_variant_get_string (value, &len); v = g_variant_get_string (value, &len);
g_assert (g_utf8_validate (v, -1, &end) && (end == v + len)); g_assert (g_utf8_validate (v, -1, &end) && (end == v + len));
g_memory_buffer_put_uint32 (mbuf, len); g_memory_buffer_put_uint32 (mbuf, len);

View File

@ -179,7 +179,8 @@ ensure_attribute_hash (void)
attribute_hash = g_hash_table_new (g_str_hash, g_str_equal); attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
#define REGISTER_ATTRIBUTE(name) G_STMT_START{\ #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); */ \ /* 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_assert (_u == G_FILE_ATTRIBUTE_ID_ ## name); \
}G_STMT_END }G_STMT_END

View File

@ -334,7 +334,7 @@ g_keyfile_settings_backend_write_one (gpointer key,
gpointer user_data) gpointer user_data)
{ {
WriteManyData *data = 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); success = set_to_keyfile (data->kfsb, key, value);
g_assert (success); g_assert (success);

View File

@ -648,8 +648,10 @@ key_state_serialise (KeyState *state)
else else
{ {
GVariantBuilder builder; 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); g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);

View File

@ -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); g_file_monitor_source_queue_event (fms, G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, child, NULL);
} }
#ifndef G_DISABLE_ASSERT
static gboolean static gboolean
is_basename (const gchar *name) is_basename (const gchar *name)
{ {
@ -336,6 +337,7 @@ is_basename (const gchar *name)
return !strchr (name, '/'); return !strchr (name, '/');
} }
#endif /* !G_DISABLE_ASSERT */
gboolean gboolean
g_file_monitor_source_handle_event (GFileMonitorSource *fms, g_file_monitor_source_handle_event (GFileMonitorSource *fms,

View File

@ -1455,7 +1455,7 @@ gint
g_settings_schema_key_to_enum (GSettingsSchemaKey *key, g_settings_schema_key_to_enum (GSettingsSchemaKey *key,
GVariant *value) GVariant *value)
{ {
gboolean it_worked; gboolean it_worked G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
guint result; guint result;
it_worked = strinfo_enum_from_string (key->strinfo, key->strinfo_length, 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); g_variant_iter_init (&iter, value);
while (g_variant_iter_next (&iter, "&s", &flag)) 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; guint flag_value;
it_worked = strinfo_enum_from_string (key->strinfo, key->strinfo_length, flag, &flag_value); it_worked = strinfo_enum_from_string (key->strinfo, key->strinfo_length, flag, &flag_value);

View File

@ -389,7 +389,9 @@ g_socket_connection_set_property (GObject *object,
static void static void
g_socket_connection_constructed (GObject *object) g_socket_connection_constructed (GObject *object)
{ {
#ifndef G_DISABLE_ASSERT
GSocketConnection *connection = G_SOCKET_CONNECTION (object); GSocketConnection *connection = G_SOCKET_CONNECTION (object);
#endif
g_assert (connection->priv->socket != NULL); g_assert (connection->priv->socket != NULL);
} }

View File

@ -575,7 +575,7 @@ initable_init (GInitable *initable,
{ {
guint64 identifier; guint64 identifier;
gint s; gint s G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
identifier = (guint64) GetProcessId (self->pid); identifier = (guint64) GetProcessId (self->pid);

View File

@ -55,7 +55,7 @@ g_inotify_file_monitor_start (GLocalFileMonitor *local_monitor,
GFileMonitorSource *source) GFileMonitorSource *source)
{ {
GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (local_monitor); 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() */ /* should already have been called, from is_supported() */
success = _ih_startup (); success = _ih_startup ();
@ -83,7 +83,9 @@ g_inotify_file_monitor_cancel (GFileMonitor *monitor)
static void static void
g_inotify_file_monitor_finalize (GObject *object) g_inotify_file_monitor_finalize (GObject *object)
{ {
#ifndef G_DISABLE_ASSERT
GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (object); GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (object);
#endif
/* must surely have been cancelled already */ /* must surely have been cancelled already */
g_assert (!inotify_monitor->sub); g_assert (!inotify_monitor->sub);