garray: Fix -Wsign-compare warnings

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2018-07-10 14:15:42 +02:00
parent 2585099a5d
commit 03bad78947

View File

@ -139,9 +139,9 @@ struct _GRealArray
g_array_elt_zero ((array), (array)->len, 1); \
}G_STMT_END
static guint g_nearest_pow (gint num) G_GNUC_CONST;
static guint g_nearest_pow (guint num) G_GNUC_CONST;
static void g_array_maybe_expand (GRealArray *array,
gint len);
guint len);
/**
* g_array_new:
@ -789,7 +789,7 @@ g_array_sort_with_data (GArray *farray,
* such power does not fit in a guint
*/
static guint
g_nearest_pow (gint num)
g_nearest_pow (guint num)
{
guint n = 1;
@ -801,7 +801,7 @@ g_nearest_pow (gint num)
static void
g_array_maybe_expand (GRealArray *array,
gint len)
guint len)
{
guint want_alloc = g_array_elt_len (array, array->len + len +
array->zero_terminated);
@ -1189,27 +1189,31 @@ g_ptr_array_set_size (GPtrArray *array,
gint length)
{
GRealPtrArray *rarray = (GRealPtrArray *)array;
guint length_unsigned;
g_return_if_fail (rarray);
g_return_if_fail (rarray->len == 0 || (rarray->len != 0 && rarray->pdata != NULL));
g_return_if_fail (length >= 0);
if (length > rarray->len)
length_unsigned = (guint) length;
if (length_unsigned > rarray->len)
{
int i;
g_ptr_array_maybe_expand (rarray, (length - rarray->len));
guint i;
g_ptr_array_maybe_expand (rarray, (length_unsigned - rarray->len));
/* This is not
* memset (array->pdata + array->len, 0,
* sizeof (gpointer) * (length - array->len));
* sizeof (gpointer) * (length_unsigned - array->len));
* to make it really portable. Remember (void*)NULL needn't be
* bitwise zero. It of course is silly not to use memset (..,0,..).
*/
for (i = rarray->len; i < length; i++)
for (i = rarray->len; i < length_unsigned; i++)
rarray->pdata[i] = NULL;
}
else if (length < rarray->len)
g_ptr_array_remove_range (array, length, rarray->len - length);
else if (length_unsigned < rarray->len)
g_ptr_array_remove_range (array, length_unsigned, rarray->len - length_unsigned);
rarray->len = length;
rarray->len = length_unsigned;
}
static gpointer