Fix various signedness warnings in glib/ghash.c

To conform to a better signedness schema, this patch change
GHashTable.size field from gint to gsize (and change accordingly the
tests with it).
This commit is contained in:
Emmanuel Fleury 2019-02-22 10:49:32 +01:00
parent a7aac03ead
commit e9f57495c6
2 changed files with 18 additions and 18 deletions

View File

@ -246,7 +246,7 @@
struct _GHashTable
{
gint size;
gsize size;
gint mod;
guint mask;
gint nnodes;
@ -279,9 +279,9 @@ typedef struct
GHashTable *hash_table;
gpointer dummy1;
gpointer dummy2;
int position;
gint position;
gboolean dummy3;
int version;
gint version;
} RealIter;
G_STATIC_ASSERT (sizeof (GHashTableIter) == sizeof (RealIter));
@ -798,7 +798,7 @@ static void
g_hash_table_resize (GHashTable *hash_table)
{
guint32 *reallocated_buckets_bitmap;
guint old_size;
gsize old_size;
gboolean is_a_set;
old_size = hash_table->size;
@ -1105,14 +1105,14 @@ g_hash_table_iter_next (GHashTableIter *iter,
#ifndef G_DISABLE_ASSERT
g_return_val_if_fail (ri->version == ri->hash_table->version, FALSE);
#endif
g_return_val_if_fail (ri->position < ri->hash_table->size, FALSE);
g_return_val_if_fail (ri->position < (gssize) ri->hash_table->size, FALSE);
position = ri->position;
do
{
position++;
if (position >= ri->hash_table->size)
if (position >= (gssize) ri->hash_table->size)
{
ri->position = position;
return FALSE;
@ -1155,7 +1155,7 @@ iter_remove_or_steal (RealIter *ri, gboolean notify)
g_return_if_fail (ri->version == ri->hash_table->version);
#endif
g_return_if_fail (ri->position >= 0);
g_return_if_fail (ri->position < ri->hash_table->size);
g_return_if_fail ((gsize) ri->position < ri->hash_table->size);
g_hash_table_remove_node (ri->hash_table, ri->position, notify);
@ -1339,7 +1339,7 @@ g_hash_table_iter_replace (GHashTableIter *iter,
g_return_if_fail (ri->version == ri->hash_table->version);
#endif
g_return_if_fail (ri->position >= 0);
g_return_if_fail (ri->position < ri->hash_table->size);
g_return_if_fail ((gsize) ri->position < ri->hash_table->size);
node_hash = ri->hash_table->hashes[ri->position];
@ -1880,7 +1880,7 @@ g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
gboolean notify)
{
guint deleted = 0;
gint i;
gsize i;
#ifndef G_DISABLE_ASSERT
gint version = hash_table->version;
#endif
@ -1989,7 +1989,7 @@ g_hash_table_foreach (GHashTable *hash_table,
GHFunc func,
gpointer user_data)
{
gint i;
gsize i;
#ifndef G_DISABLE_ASSERT
gint version;
#endif
@ -2047,7 +2047,7 @@ g_hash_table_find (GHashTable *hash_table,
GHRFunc predicate,
gpointer user_data)
{
gint i;
gsize i;
#ifndef G_DISABLE_ASSERT
gint version;
#endif
@ -2119,7 +2119,7 @@ g_hash_table_size (GHashTable *hash_table)
GList *
g_hash_table_get_keys (GHashTable *hash_table)
{
gint i;
gsize i;
GList *retval;
g_return_val_if_fail (hash_table != NULL, NULL);
@ -2167,7 +2167,7 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table,
guint *length)
{
gpointer *result;
guint i, j = 0;
gsize i, j = 0;
result = g_new (gpointer, hash_table->nnodes + 1);
for (i = 0; i < hash_table->size; i++)
@ -2205,7 +2205,7 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table,
GList *
g_hash_table_get_values (GHashTable *hash_table)
{
gint i;
gsize i;
GList *retval;
g_return_val_if_fail (hash_table != NULL, NULL);

View File

@ -183,7 +183,7 @@ static guint
honeyman_hash (gconstpointer key)
{
const gchar *name = (const gchar *) key;
gint size;
gsize size;
guint sum = 0;
g_assert (name != NULL);
@ -1347,7 +1347,7 @@ test_lookup_extended (void)
struct _GHashTable
{
gint size;
gsize size;
gint mod;
guint mask;
gint nnodes;
@ -1374,7 +1374,7 @@ struct _GHashTable
static void
count_keys (GHashTable *h, gint *unused, gint *occupied, gint *tombstones)
{
gint i;
gsize i;
*unused = 0;
*occupied = 0;
@ -1410,7 +1410,7 @@ fetch_key_or_value (gpointer a, guint index, gboolean is_big)
static void
check_data (GHashTable *h)
{
gint i;
gsize i;
for (i = 0; i < h->size; i++)
{