Commit 3806c34d authored by Philip Withnall's avatar Philip Withnall

Merge branch '1655-int-signedness-casts' into 'master'

gvariant-parser: Add explicit unsigned-to-signed casts

Closes #1655

See merge request GNOME/glib!600
parents ab40b242 e3e4a097
Pipeline #53075 passed with stages
in 10 minutes and 49 seconds
......@@ -1921,7 +1921,7 @@ number_get_value (AST *ast,
case 'n':
if (abs_val - negative > G_MAXINT16)
return number_overflow (ast, type, error);
return g_variant_new_int16 (negative ? -abs_val : abs_val);
return g_variant_new_int16 (negative ? -((gint16) abs_val) : abs_val);
case 'q':
if (negative || abs_val > G_MAXUINT16)
......@@ -1931,7 +1931,7 @@ number_get_value (AST *ast,
case 'i':
if (abs_val - negative > G_MAXINT32)
return number_overflow (ast, type, error);
return g_variant_new_int32 (negative ? -abs_val : abs_val);
return g_variant_new_int32 (negative ? -((gint32) abs_val) : abs_val);
case 'u':
if (negative || abs_val > G_MAXUINT32)
......@@ -1941,7 +1941,7 @@ number_get_value (AST *ast,
case 'x':
if (abs_val - negative > G_MAXINT64)
return number_overflow (ast, type, error);
return g_variant_new_int64 (negative ? -abs_val : abs_val);
return g_variant_new_int64 (negative ? -((gint64) abs_val) : abs_val);
case 't':
if (negative)
......@@ -1951,7 +1951,7 @@ number_get_value (AST *ast,
case 'h':
if (abs_val - negative > G_MAXINT32)
return number_overflow (ast, type, error);
return g_variant_new_handle (negative ? -abs_val : abs_val);
return g_variant_new_handle (negative ? -((gint32) abs_val) : abs_val);
default:
return ast_type_error (ast, type, error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment