Skip to content

Commit

Permalink
Fixing various warnings in glib/gvariant-parser.c
Browse files Browse the repository at this point in the history
glib/gvariant-parser.c: In function ‘number_get_value’:
glib/gvariant-parser.c:1924:46: error: operand of ?: changes signedness from ‘int’ to ‘guint64’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
       return g_variant_new_int16 (negative ? -((gint16) abs_val) : abs_val);
                                             ^~~~~~~~~~~~~~~~~~~
glib/gvariant-parser.c:1934:46: error: operand of ?: changes signedness from ‘int’ to ‘guint64’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
       return g_variant_new_int32 (negative ? -((gint32) abs_val) : abs_val);
                                              ^~~~~~~~~~~~~~~~~~~
glib/gvariant-parser.c:1944:46: error: operand of ?: changes signedness from ‘long int’ to ‘guint64’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
       return g_variant_new_int64 (negative ? -((gint64) abs_val) : abs_val);
                                                  ^~~~~~~~~~~~~~~~~~~
glib/gvariant-parser.c:1954:47: error: operand of ?: changes signedness from ‘int’ to ‘guint64’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
       return g_variant_new_handle (negative ? -((gint32) abs_val) : abs_val);
                                                   ^~~~~~~~~~~~~~~~~~~
glib/gvariant-parser.c: In function ‘g_variant_parse_error_print_context’:
glib/gvariant-parser.c:2785:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
       if (point >= strlen (source_str))
                 ^~
  • Loading branch information
perror committed Mar 17, 2019
1 parent 357c3db commit a7aac03
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions glib/gvariant-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,8 @@ number_get_value (AST *ast,
return number_overflow (ast, type, error);
if (negative && abs_val > G_MAXINT16)
return g_variant_new_int16 (G_MININT16);
return g_variant_new_int16 (negative ? -((gint16) abs_val) : abs_val);
return g_variant_new_int16 (negative ?
-((gint16) abs_val) : ((gint16) abs_val));

case 'q':
if (negative || abs_val > G_MAXUINT16)
Expand All @@ -1950,7 +1951,8 @@ number_get_value (AST *ast,
return number_overflow (ast, type, error);
if (negative && abs_val > G_MAXINT32)
return g_variant_new_int32 (G_MININT32);
return g_variant_new_int32 (negative ? -((gint32) abs_val) : abs_val);
return g_variant_new_int32 (negative ?
-((gint32) abs_val) : ((gint32) abs_val));

case 'u':
if (negative || abs_val > G_MAXUINT32)
Expand All @@ -1962,7 +1964,8 @@ number_get_value (AST *ast,
return number_overflow (ast, type, error);
if (negative && abs_val > G_MAXINT64)
return g_variant_new_int64 (G_MININT64);
return g_variant_new_int64 (negative ? -((gint64) abs_val) : abs_val);
return g_variant_new_int64 (negative ?
-((gint64) abs_val) : ((gint64) abs_val));

case 't':
if (negative)
Expand All @@ -1974,7 +1977,8 @@ number_get_value (AST *ast,
return number_overflow (ast, type, error);
if (negative && abs_val > G_MAXINT32)
return g_variant_new_handle (G_MININT32);
return g_variant_new_handle (negative ? -((gint32) abs_val) : abs_val);
return g_variant_new_handle (negative ?
-((gint32) abs_val) : ((gint32) abs_val));

default:
return ast_type_error (ast, type, error);
Expand Down Expand Up @@ -2630,7 +2634,7 @@ g_variant_builder_add_parsed (GVariantBuilder *builder,
static gboolean
parse_num (const gchar *num,
const gchar *limit,
gint *result)
guint *result)
{
gchar *endptr;
gint64 bignum;
Expand All @@ -2643,7 +2647,7 @@ parse_num (const gchar *num,
if (bignum < 0 || bignum > G_MAXINT)
return FALSE;

*result = bignum;
*result = (guint) bignum;

return TRUE;
}
Expand Down Expand Up @@ -2799,7 +2803,7 @@ g_variant_parse_error_print_context (GError *error,

if (dash == NULL || colon < dash)
{
gint point;
guint point;

/* we have a single point */
if (!parse_num (error->message, colon, &point))
Expand All @@ -2817,7 +2821,7 @@ g_variant_parse_error_print_context (GError *error,
/* We have one or two ranges... */
if (comma && comma < colon)
{
gint start1, end1, start2, end2;
guint start1, end1, start2, end2;
const gchar *dash2;

/* Two ranges */
Expand All @@ -2833,7 +2837,7 @@ g_variant_parse_error_print_context (GError *error,
}
else
{
gint start, end;
guint start, end;

/* One range */
if (!parse_num (error->message, dash, &start) || !parse_num (dash + 1, colon, &end))
Expand Down

0 comments on commit a7aac03

Please sign in to comment.