[glib: 1/9] Fix several signedness warnings in gio/tests/unix-streams.c




commit a9652620045172cafd2f863df8b3260ccde6b469
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Fri Nov 20 19:58:20 2020 +0100

    Fix several signedness warnings in gio/tests/unix-streams.c
    
    gio/tests/unix-streams.c: In function ‘test_write_async_wouldblock’:
    gio/tests/unix-streams.c:692:17: error: comparison of integer expressions of different signedness: 
‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’}
      692 |   for (i = 0; i < 4 * pipe_capacity; i++)
          |                 ^
    gio/tests/unix-streams.c: In function ‘test_writev_async_wouldblock’:
    gio/tests/unix-streams.c:780:17: error: comparison of integer expressions of different signedness: 
‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’}
      780 |   for (i = 0; i < 4 * pipe_capacity; i++)
          |                 ^

 gio/tests/unix-streams.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/gio/tests/unix-streams.c b/gio/tests/unix-streams.c
index 5ec829919..407a67dbd 100644
--- a/gio/tests/unix-streams.c
+++ b/gio/tests/unix-streams.c
@@ -474,8 +474,9 @@ test_write_wouldblock (void)
   gint fd[2];
   GError *err = NULL;
   guint8 data_write[1024], data_read[1024];
-  guint i;
-  gint pipe_capacity;
+  gsize i;
+  int retval;
+  gsize pipe_capacity;
 
   for (i = 0; i < sizeof (data_write); i++)
     data_write[i] = i;
@@ -483,7 +484,9 @@ test_write_wouldblock (void)
   g_assert_cmpint (pipe (fd), ==, 0);
 
   g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0);
-  pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL);
+  retval = fcntl (fd[0], F_GETPIPE_SZ);
+  g_assert_cmpint (retval, >=, 0);
+  pipe_capacity = (gsize) retval;
   g_assert_cmpint (pipe_capacity, >=, 4096);
   g_assert_cmpint (pipe_capacity % 1024, >=, 0);
 
@@ -552,10 +555,11 @@ test_writev_wouldblock (void)
   gint fd[2];
   GError *err = NULL;
   guint8 data_write[1024], data_read[1024];
-  guint i;
+  gsize i;
+  int retval;
+  gsize pipe_capacity;
   GOutputVector vectors[4];
   GPollableReturn res;
-  gint pipe_capacity;
 
   for (i = 0; i < sizeof (data_write); i++)
     data_write[i] = i;
@@ -563,7 +567,9 @@ test_writev_wouldblock (void)
   g_assert_cmpint (pipe (fd), ==, 0);
 
   g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0);
-  pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL);
+  retval = fcntl (fd[0], F_GETPIPE_SZ);
+  g_assert_cmpint (retval, >=, 0);
+  pipe_capacity = (gsize) retval;
   g_assert_cmpint (pipe_capacity, >=, 4096);
   g_assert_cmpint (pipe_capacity % 1024, >=, 0);
 
@@ -667,8 +673,9 @@ test_write_async_wouldblock (void)
   GUnixOutputStream *os;
   gint fd[2];
   guint8 *data, *data_read;
-  guint i;
-  gint pipe_capacity;
+  gsize i;
+  int retval;
+  gsize pipe_capacity;
   gsize bytes_written = 0, bytes_read = 0;
 
   g_assert_cmpint (pipe (fd), ==, 0);
@@ -685,7 +692,9 @@ test_write_async_wouldblock (void)
   g_unix_set_fd_nonblocking (fd[1], TRUE, NULL);
 
   g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0);
-  pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL);
+  retval = fcntl (fd[0], F_GETPIPE_SZ);
+  g_assert_cmpint (retval, >=, 0);
+  pipe_capacity = (gsize) retval;
   g_assert_cmpint (pipe_capacity, >=, 4096);
 
   data = g_new (guint8, 4 * pipe_capacity);
@@ -754,8 +763,9 @@ test_writev_async_wouldblock (void)
   GUnixOutputStream *os;
   gint fd[2];
   guint8 *data, *data_read;
-  guint i;
-  gint pipe_capacity;
+  gsize i;
+  int retval;
+  gsize pipe_capacity;
   gsize bytes_written = 0, bytes_read = 0;
   GOutputVector vectors[4];
 
@@ -773,7 +783,9 @@ test_writev_async_wouldblock (void)
   g_unix_set_fd_nonblocking (fd[1], TRUE, NULL);
 
   g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0);
-  pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL);
+  retval = fcntl (fd[0], F_GETPIPE_SZ);
+  g_assert_cmpint (retval, >=, 0);
+  pipe_capacity = (gsize) retval;
   g_assert_cmpint (pipe_capacity, >=, 4096);
 
   data = g_new (guint8, 4 * pipe_capacity);


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