glib: 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:23:41 +00:00
parent 1b50643c99
commit faa1d63cab
5 changed files with 17 additions and 2 deletions

View File

@ -1304,7 +1304,10 @@ parse_iso8601_date (const gchar *text, gsize length,
static GTimeZone * static GTimeZone *
parse_iso8601_timezone (const gchar *text, gsize length, gssize *tz_offset) parse_iso8601_timezone (const gchar *text, gsize length, gssize *tz_offset)
{ {
gint i, tz_length, offset_sign = 1, offset_hours, offset_minutes; gint i, tz_length, offset_hours, offset_minutes;
#ifndef G_DISABLE_ASSERT
gint offset_sign = 1;
#endif
GTimeZone *tz; GTimeZone *tz;
/* UTC uses Z suffix */ /* UTC uses Z suffix */
@ -1318,7 +1321,9 @@ parse_iso8601_timezone (const gchar *text, gsize length, gssize *tz_offset)
for (i = length - 1; i >= 0; i--) for (i = length - 1; i >= 0; i--)
if (text[i] == '+' || text[i] == '-') if (text[i] == '+' || text[i] == '-')
{ {
#ifndef G_DISABLE_ASSERT
offset_sign = text[i] == '-' ? -1 : 1; offset_sign = text[i] == '-' ? -1 : 1;
#endif
break; break;
} }
if (i < 0) if (i < 0)

View File

@ -1311,7 +1311,9 @@ g_io_channel_set_encoding (GIOChannel *channel,
GError **error) GError **error)
{ {
GIConv read_cd, write_cd; GIConv read_cd, write_cd;
#ifndef G_DISABLE_ASSERT
gboolean did_encode; gboolean did_encode;
#endif
g_return_val_if_fail (channel != NULL, G_IO_STATUS_ERROR); g_return_val_if_fail (channel != NULL, G_IO_STATUS_ERROR);
g_return_val_if_fail ((error == NULL) || (*error == NULL), G_IO_STATUS_ERROR); g_return_val_if_fail ((error == NULL) || (*error == NULL), G_IO_STATUS_ERROR);
@ -1335,7 +1337,9 @@ g_io_channel_set_encoding (GIOChannel *channel,
channel->partial_write_buf[0] = '\0'; channel->partial_write_buf[0] = '\0';
} }
#ifndef G_DISABLE_ASSERT
did_encode = channel->do_encode; did_encode = channel->do_encode;
#endif
if (!encoding || strcmp (encoding, "UTF8") == 0 || strcmp (encoding, "UTF-8") == 0) if (!encoding || strcmp (encoding, "UTF8") == 0 || strcmp (encoding, "UTF-8") == 0)
{ {

View File

@ -362,7 +362,7 @@ static void
token_stream_assert (TokenStream *stream, token_stream_assert (TokenStream *stream,
const gchar *token) const gchar *token)
{ {
gboolean correct_token; gboolean correct_token G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
correct_token = token_stream_consume (stream, token); correct_token = token_stream_consume (stream, token);
g_assert (correct_token); g_assert (correct_token);

View File

@ -1084,12 +1084,16 @@ g_variant_type_key (const GVariantType *type)
const GVariantType * const GVariantType *
g_variant_type_value (const GVariantType *type) g_variant_type_value (const GVariantType *type)
{ {
#ifndef G_DISABLE_ASSERT
const gchar *type_string; const gchar *type_string;
#endif
g_return_val_if_fail (g_variant_type_check (type), NULL); g_return_val_if_fail (g_variant_type_check (type), NULL);
#ifndef G_DISABLE_ASSERT
type_string = g_variant_type_peek_string (type); type_string = g_variant_type_peek_string (type);
g_assert (type_string[0] == '{'); g_assert (type_string[0] == '{');
#endif
return g_variant_type_next (g_variant_type_key (type)); return g_variant_type_next (g_variant_type_key (type));
} }

View File

@ -157,6 +157,7 @@ static void
g_variant_type_info_check (const GVariantTypeInfo *info, g_variant_type_info_check (const GVariantTypeInfo *info,
char container_class) char container_class)
{ {
#ifndef G_DISABLE_ASSERT
g_assert (!container_class || info->container_class == container_class); g_assert (!container_class || info->container_class == container_class);
/* alignment can only be one of these */ /* alignment can only be one of these */
@ -185,6 +186,7 @@ g_variant_type_info_check (const GVariantTypeInfo *info,
g_assert (0 <= index && index < 24); g_assert (0 <= index && index < 24);
g_assert (g_variant_type_info_basic_chars[index][0] != ' '); g_assert (g_variant_type_info_basic_chars[index][0] != ' ');
} }
#endif /* !G_DISABLE_ASSERT */
} }
/* < private > /* < private >