mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Fixing various warnings in glib/gvariant-parser.c
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)) ^~
This commit is contained in:
parent
357c3db942
commit
a7aac03ead
@ -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)
|
||||
@ -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)
|
||||
@ -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)
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -2643,7 +2647,7 @@ parse_num (const gchar *num,
|
||||
if (bignum < 0 || bignum > G_MAXINT)
|
||||
return FALSE;
|
||||
|
||||
*result = bignum;
|
||||
*result = (guint) bignum;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -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))
|
||||
@ -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 */
|
||||
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user