[glib: 10/15] Fix signedness warnings in glib/tests/queue.c




commit a1758820d700bde333e7a550ba5608be730e285a
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Thu Oct 15 12:08:06 2020 +0200

    Fix signedness warnings in glib/tests/queue.c
    
    glib/tests/queue.c: In function ‘check_integrity’:
    glib/tests/queue.c:36:15: error: comparison of integer expressions of different signedness: ‘gint’ {aka 
‘int’} and ‘guint’ {aka ‘unsigned int’}
       36 |   g_assert (n == queue->length);
          |               ^~
    glib/gmacros.h:939:25: note: in definition of macro ‘G_LIKELY’
      939 | #define G_LIKELY(expr) (expr)
          |                         ^~~~
    glib/tests/queue.c:36:3: note: in expansion of macro ‘g_assert’
       36 |   g_assert (n == queue->length);
          |   ^~~~~~~~
    glib/tests/queue.c:47:15: error: comparison of integer expressions of different signedness: ‘gint’ {aka 
‘int’} and ‘guint’ {aka ‘unsigned int’}
       47 |   g_assert (n == queue->length);
          |               ^~
    glib/gmacros.h:939:25: note: in definition of macro ‘G_LIKELY’
      939 | #define G_LIKELY(expr) (expr)
          |                         ^~~~
    glib/tests/queue.c:47:3: note: in expansion of macro ‘g_assert’
       47 |   g_assert (n == queue->length);
          |   ^~~~~~~~
    glib/tests/queue.c: In function ‘random_test’:
    glib/tests/queue.c:274:36: error: comparison of integer expressions of different signedness: ‘guint’ {aka 
‘unsigned int’} and ‘int’
      274 |             g_assert (qinf->length == l);
          |                                    ^~
    glib/gmacros.h:939:25: note: in definition of macro ‘G_LIKELY’
      939 | #define G_LIKELY(expr) (expr)
          |                         ^~~~
    glib/tests/queue.c:274:13: note: in expansion of macro ‘g_assert’
      274 |             g_assert (qinf->length == l);
          |             ^~~~~~~~
    glib/tests/queue.c:419:21: error: comparison of integer expressions of different signedness: ‘int’ and 
‘guint’ {aka ‘unsigned int’}
      419 |               if (n == q->length - 1)
          |                     ^~
    glib/tests/queue.c:425:31: error: comparison of integer expressions of different signedness: ‘int’ and 
‘guint’ {aka ‘unsigned int’}
      425 |               if (n >= 0 && n < q->length)
          |                               ^
    glib/tests/queue.c:453:30: error: comparison of integer expressions of different signedness: ‘int’ and 
‘guint’ {aka ‘unsigned int’}
      453 |               if (n < 0 || n >= q->length)
          |                              ^~
    glib/tests/queue.c:640:21: error: comparison of integer expressions of different signedness: ‘int’ and 
‘guint’ {aka ‘unsigned int’}
      640 |               if (n == g_queue_get_length (q) - 1)
          |                     ^~

 glib/tests/queue.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/glib/tests/queue.c b/glib/tests/queue.c
index dd9dd2127..e77821372 100644
--- a/glib/tests/queue.c
+++ b/glib/tests/queue.c
@@ -14,7 +14,7 @@ check_integrity (GQueue *queue)
   GList *last;
   GList *links;
   GList *link;
-  gint n;
+  guint n;
 
   g_assert (queue->length < 4000000000u);
 
@@ -266,7 +266,7 @@ random_test (gconstpointer d)
           break;
         case GET_LENGTH:
           {
-            int l;
+            guint l;
 
             l = g_queue_get_length (q);
 
@@ -416,13 +416,13 @@ random_test (gconstpointer d)
               int n = get_random_position (q, TRUE);
               gpointer elm = g_queue_peek_nth (q, n);
 
-              if (n == q->length - 1)
+              if (n == (int) (q->length - 1))
                 qinf->tail = qinf->tail->prev;
 
               if (n == 0)
                 qinf->head = qinf->head->next;
 
-              if (n >= 0 && n < q->length)
+              if (n >= 0 && (guint) n < q->length)
                 qinf->length--;
 
               g_assert (elm == g_queue_pop_nth (q, n));
@@ -450,7 +450,7 @@ random_test (gconstpointer d)
             {
               GList *list;
               int n = get_random_position (q, TRUE);
-              if (n < 0 || n >= q->length)
+              if (n < 0 || (guint) n >= q->length)
                 {
                   g_assert (g_queue_peek_nth (q, n) == NULL);
                 }
@@ -637,7 +637,7 @@ random_test (gconstpointer d)
             {
               int n = get_random_position (q, FALSE);
 
-              if (n == g_queue_get_length (q) - 1)
+              if (n == (int) (g_queue_get_length (q) - 1))
                 qinf->tail = qinf->tail->prev;
 
               if (n == 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]