mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Merge branch 'sign-compare' into 'master'
Fix some -Wsign-compare warnings See merge request GNOME/glib!162
This commit is contained in:
commit
c182cd68c9
@ -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
|
||||
|
@ -372,7 +372,7 @@ g_queue_push_nth (GQueue *queue,
|
||||
{
|
||||
g_return_if_fail (queue != NULL);
|
||||
|
||||
if (n < 0 || n >= queue->length)
|
||||
if (n < 0 || (guint) n >= queue->length)
|
||||
{
|
||||
g_queue_push_tail (queue, data);
|
||||
return;
|
||||
@ -475,7 +475,7 @@ g_queue_push_nth_link (GQueue *queue,
|
||||
g_return_if_fail (queue != NULL);
|
||||
g_return_if_fail (link_ != NULL);
|
||||
|
||||
if (n < 0 || n >= queue->length)
|
||||
if (n < 0 || (guint) n >= queue->length)
|
||||
{
|
||||
g_queue_push_tail_link (queue, link_);
|
||||
return;
|
||||
@ -749,7 +749,7 @@ g_queue_peek_nth_link (GQueue *queue,
|
||||
guint n)
|
||||
{
|
||||
GList *link;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (queue != NULL, NULL);
|
||||
|
||||
|
@ -388,7 +388,7 @@ g_rand_set_seed_array (GRand *rand,
|
||||
const guint32 *seed,
|
||||
guint seed_length)
|
||||
{
|
||||
int i, j, k;
|
||||
guint i, j, k;
|
||||
|
||||
g_return_if_fail (rand != NULL);
|
||||
g_return_if_fail (seed_length >= 1);
|
||||
|
@ -1054,7 +1054,7 @@ g_variant_type_new_tuple_slow (const GVariantType * const *items,
|
||||
* happen only in truly insane code, so it can be slow.
|
||||
*/
|
||||
GString *string;
|
||||
gsize i;
|
||||
gint i;
|
||||
|
||||
string = g_string_new ("(");
|
||||
for (i = 0; i < length; i++)
|
||||
@ -1080,16 +1080,19 @@ g_variant_type_new_tuple (const GVariantType * const *items,
|
||||
char buffer[1024];
|
||||
gsize offset;
|
||||
gsize i;
|
||||
gsize length_unsigned;
|
||||
|
||||
g_return_val_if_fail (length == 0 || items != NULL, NULL);
|
||||
|
||||
if (length < 0)
|
||||
for (length = 0; items[length] != NULL; length++);
|
||||
for (length_unsigned = 0; items[length_unsigned] != NULL; length_unsigned++);
|
||||
else
|
||||
length_unsigned = (gsize) length;
|
||||
|
||||
offset = 0;
|
||||
buffer[offset++] = '(';
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < length_unsigned; i++)
|
||||
{
|
||||
const GVariantType *type;
|
||||
gsize size;
|
||||
@ -1100,7 +1103,7 @@ g_variant_type_new_tuple (const GVariantType * const *items,
|
||||
size = g_variant_type_get_string_length (type);
|
||||
|
||||
if (offset + size >= sizeof buffer) /* leave room for ')' */
|
||||
return g_variant_type_new_tuple_slow (items, length);
|
||||
return g_variant_type_new_tuple_slow (items, length_unsigned);
|
||||
|
||||
memcpy (&buffer[offset], type, size);
|
||||
offset += size;
|
||||
|
Loading…
Reference in New Issue
Block a user