mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 04:02:09 +01:00
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:
parent
a7aac03ead
commit
e9f57495c6
28
glib/ghash.c
28
glib/ghash.c
@ -246,7 +246,7 @@
|
|||||||
|
|
||||||
struct _GHashTable
|
struct _GHashTable
|
||||||
{
|
{
|
||||||
gint size;
|
gsize size;
|
||||||
gint mod;
|
gint mod;
|
||||||
guint mask;
|
guint mask;
|
||||||
gint nnodes;
|
gint nnodes;
|
||||||
@ -279,9 +279,9 @@ typedef struct
|
|||||||
GHashTable *hash_table;
|
GHashTable *hash_table;
|
||||||
gpointer dummy1;
|
gpointer dummy1;
|
||||||
gpointer dummy2;
|
gpointer dummy2;
|
||||||
int position;
|
gint position;
|
||||||
gboolean dummy3;
|
gboolean dummy3;
|
||||||
int version;
|
gint version;
|
||||||
} RealIter;
|
} RealIter;
|
||||||
|
|
||||||
G_STATIC_ASSERT (sizeof (GHashTableIter) == sizeof (RealIter));
|
G_STATIC_ASSERT (sizeof (GHashTableIter) == sizeof (RealIter));
|
||||||
@ -798,7 +798,7 @@ static void
|
|||||||
g_hash_table_resize (GHashTable *hash_table)
|
g_hash_table_resize (GHashTable *hash_table)
|
||||||
{
|
{
|
||||||
guint32 *reallocated_buckets_bitmap;
|
guint32 *reallocated_buckets_bitmap;
|
||||||
guint old_size;
|
gsize old_size;
|
||||||
gboolean is_a_set;
|
gboolean is_a_set;
|
||||||
|
|
||||||
old_size = hash_table->size;
|
old_size = hash_table->size;
|
||||||
@ -1105,14 +1105,14 @@ g_hash_table_iter_next (GHashTableIter *iter,
|
|||||||
#ifndef G_DISABLE_ASSERT
|
#ifndef G_DISABLE_ASSERT
|
||||||
g_return_val_if_fail (ri->version == ri->hash_table->version, FALSE);
|
g_return_val_if_fail (ri->version == ri->hash_table->version, FALSE);
|
||||||
#endif
|
#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;
|
position = ri->position;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
position++;
|
position++;
|
||||||
if (position >= ri->hash_table->size)
|
if (position >= (gssize) ri->hash_table->size)
|
||||||
{
|
{
|
||||||
ri->position = position;
|
ri->position = position;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1155,7 +1155,7 @@ iter_remove_or_steal (RealIter *ri, gboolean notify)
|
|||||||
g_return_if_fail (ri->version == ri->hash_table->version);
|
g_return_if_fail (ri->version == ri->hash_table->version);
|
||||||
#endif
|
#endif
|
||||||
g_return_if_fail (ri->position >= 0);
|
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);
|
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);
|
g_return_if_fail (ri->version == ri->hash_table->version);
|
||||||
#endif
|
#endif
|
||||||
g_return_if_fail (ri->position >= 0);
|
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];
|
node_hash = ri->hash_table->hashes[ri->position];
|
||||||
|
|
||||||
@ -1880,7 +1880,7 @@ g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
|
|||||||
gboolean notify)
|
gboolean notify)
|
||||||
{
|
{
|
||||||
guint deleted = 0;
|
guint deleted = 0;
|
||||||
gint i;
|
gsize i;
|
||||||
#ifndef G_DISABLE_ASSERT
|
#ifndef G_DISABLE_ASSERT
|
||||||
gint version = hash_table->version;
|
gint version = hash_table->version;
|
||||||
#endif
|
#endif
|
||||||
@ -1989,7 +1989,7 @@ g_hash_table_foreach (GHashTable *hash_table,
|
|||||||
GHFunc func,
|
GHFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
#ifndef G_DISABLE_ASSERT
|
#ifndef G_DISABLE_ASSERT
|
||||||
gint version;
|
gint version;
|
||||||
#endif
|
#endif
|
||||||
@ -2047,7 +2047,7 @@ g_hash_table_find (GHashTable *hash_table,
|
|||||||
GHRFunc predicate,
|
GHRFunc predicate,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
#ifndef G_DISABLE_ASSERT
|
#ifndef G_DISABLE_ASSERT
|
||||||
gint version;
|
gint version;
|
||||||
#endif
|
#endif
|
||||||
@ -2119,7 +2119,7 @@ g_hash_table_size (GHashTable *hash_table)
|
|||||||
GList *
|
GList *
|
||||||
g_hash_table_get_keys (GHashTable *hash_table)
|
g_hash_table_get_keys (GHashTable *hash_table)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
GList *retval;
|
GList *retval;
|
||||||
|
|
||||||
g_return_val_if_fail (hash_table != NULL, NULL);
|
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)
|
guint *length)
|
||||||
{
|
{
|
||||||
gpointer *result;
|
gpointer *result;
|
||||||
guint i, j = 0;
|
gsize i, j = 0;
|
||||||
|
|
||||||
result = g_new (gpointer, hash_table->nnodes + 1);
|
result = g_new (gpointer, hash_table->nnodes + 1);
|
||||||
for (i = 0; i < hash_table->size; i++)
|
for (i = 0; i < hash_table->size; i++)
|
||||||
@ -2205,7 +2205,7 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table,
|
|||||||
GList *
|
GList *
|
||||||
g_hash_table_get_values (GHashTable *hash_table)
|
g_hash_table_get_values (GHashTable *hash_table)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
GList *retval;
|
GList *retval;
|
||||||
|
|
||||||
g_return_val_if_fail (hash_table != NULL, NULL);
|
g_return_val_if_fail (hash_table != NULL, NULL);
|
||||||
|
@ -183,7 +183,7 @@ static guint
|
|||||||
honeyman_hash (gconstpointer key)
|
honeyman_hash (gconstpointer key)
|
||||||
{
|
{
|
||||||
const gchar *name = (const gchar *) key;
|
const gchar *name = (const gchar *) key;
|
||||||
gint size;
|
gsize size;
|
||||||
guint sum = 0;
|
guint sum = 0;
|
||||||
|
|
||||||
g_assert (name != NULL);
|
g_assert (name != NULL);
|
||||||
@ -1347,7 +1347,7 @@ test_lookup_extended (void)
|
|||||||
|
|
||||||
struct _GHashTable
|
struct _GHashTable
|
||||||
{
|
{
|
||||||
gint size;
|
gsize size;
|
||||||
gint mod;
|
gint mod;
|
||||||
guint mask;
|
guint mask;
|
||||||
gint nnodes;
|
gint nnodes;
|
||||||
@ -1374,7 +1374,7 @@ struct _GHashTable
|
|||||||
static void
|
static void
|
||||||
count_keys (GHashTable *h, gint *unused, gint *occupied, gint *tombstones)
|
count_keys (GHashTable *h, gint *unused, gint *occupied, gint *tombstones)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
|
|
||||||
*unused = 0;
|
*unused = 0;
|
||||||
*occupied = 0;
|
*occupied = 0;
|
||||||
@ -1410,7 +1410,7 @@ fetch_key_or_value (gpointer a, guint index, gboolean is_big)
|
|||||||
static void
|
static void
|
||||||
check_data (GHashTable *h)
|
check_data (GHashTable *h)
|
||||||
{
|
{
|
||||||
gint i;
|
gsize i;
|
||||||
|
|
||||||
for (i = 0; i < h->size; i++)
|
for (i = 0; i < h->size; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user