[glib: 23/25] Fix various signedness warnings in glib/ghash.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 23/25] Fix various signedness warnings in glib/ghash.c
- Date: Tue, 19 Mar 2019 11:04:46 +0000 (UTC)
commit e9f57495c6f614be2da92bad2d0b17f93ee80974
Author: Emmanuel Fleury <emmanuel fleury u-bordeaux fr>
Date: Fri Feb 22 10:49:32 2019 +0100
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).
glib/ghash.c | 28 ++++++++++++++--------------
glib/tests/hash.c | 8 ++++----
2 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index dac5552bd..1f3a5ed36 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -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);
diff --git a/glib/tests/hash.c b/glib/tests/hash.c
index 16acbbf2a..6b0197101 100644
--- a/glib/tests/hash.c
+++ b/glib/tests/hash.c
@@ -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++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]