[glib: 6/8] Fix signedness warnings in glib/gpoll.c




commit b89967a14d41db8fc131e906ed1d88fe13fc567b
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Fri May 14 13:03:01 2021 +0200

    Fix signedness warnings in glib/gpoll.c
    
    glib/gpoll.c: In function 'poll_rest':
    ../glib/gpoll.c:165:22: warning: comparison of integer expressions of different signedness: 'gint' {aka 
'int'} and 'unsigned int'
           if (timeout_ms == INFINITE)
                          ^~
    glib/gpoll.c:219:18: warning: comparison of unsigned expression >= 0 is always true
       else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles)
                      ^~
    glib/gpoll.c: In function 'poll_single_thread':
    glib/gpoll.c:281:44: warning: comparison of integer expressions of different signedness: 'gint' {aka 
'int'} and 'unsigned int'
           if (retval == 0 && (data->timeout_ms == INFINITE || data->timeout_ms > 0))
                                                ^~
    glib/gpoll.c: In function 'g_poll':
    glib/gpoll.c:477:52: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 
'long unsigned int'} and 'int'
             retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                                        ^~
    glib/gpoll.c:477:60: warning: operand of ?: changes signedness from 'int' to 'long unsigned int' due to 
unsignedness of other operand
             retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                                                ^~
    glib/gpoll.c:477:33: warning: operand of ?: changes signedness from 'int' to 'long unsigned int' due to 
unsignedness of other operand
             retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                     ^~

 glib/gpoll.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/glib/gpoll.c b/glib/gpoll.c
index 2681d91f9..bd29ea623 100644
--- a/glib/gpoll.c
+++ b/glib/gpoll.c
@@ -135,7 +135,7 @@ poll_rest (GPollFD *msg_fd,
            HANDLE  *handles,
            GPollFD *handle_to_fd[],
            gint     nhandles,
-           gint     timeout_ms)
+           DWORD    timeout_ms)
 {
   DWORD ready;
   GPollFD *f;
@@ -147,7 +147,7 @@ poll_rest (GPollFD *msg_fd,
        * -> Use MsgWaitForMultipleObjectsEx
        */
       if (_g_main_poll_debug)
-       g_print ("  MsgWaitForMultipleObjectsEx(%d, %d)\n", nhandles, timeout_ms);
+       g_print ("  MsgWaitForMultipleObjectsEx(%d, %lu)\n", nhandles, timeout_ms);
 
       ready = MsgWaitForMultipleObjectsEx (nhandles, handles, timeout_ms,
                                           QS_ALLINPUT, MWMO_ALERTABLE);
@@ -177,7 +177,7 @@ poll_rest (GPollFD *msg_fd,
        * -> Use WaitForMultipleObjectsEx
        */
       if (_g_main_poll_debug)
-       g_print ("  WaitForMultipleObjectsEx(%d, %d)\n", nhandles, timeout_ms);
+       g_print ("  WaitForMultipleObjectsEx(%d, %lu)\n", nhandles, timeout_ms);
 
       ready = WaitForMultipleObjectsEx (nhandles, handles, FALSE, timeout_ms, TRUE);
       if (ready == WAIT_FAILED)
@@ -216,7 +216,7 @@ poll_rest (GPollFD *msg_fd,
       recursed_result = poll_rest (NULL, stop_fd, handles, handle_to_fd, nhandles, 0);
       return (recursed_result == -1) ? -1 : 1 + recursed_result;
     }
-  else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles)
+  else if (ready < WAIT_OBJECT_0 + nhandles)
     {
       int retval;
 
@@ -258,7 +258,7 @@ typedef struct
   GPollFD *msg_fd;
   GPollFD *stop_fd;
   gint nhandles;
-  gint timeout_ms;
+  DWORD    timeout_ms;
 } GWin32PollThreadData;
 
 static gint
@@ -295,7 +295,7 @@ poll_single_thread (GWin32PollThreadData *data)
 static void
 fill_poll_thread_data (GPollFD              *fds,
                        guint                 nfds,
-                       gint                  timeout_ms,
+                       DWORD                 timeout_ms,
                        GPollFD              *stop_fd,
                        GWin32PollThreadData *data)
 {
@@ -474,7 +474,7 @@ g_poll (GPollFD *fds,
   for (i = 0; i < nthreads; i++)
     {
       if (GetExitCodeThread (thread_handles[i], &thread_retval))
-        retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
+        retval = (retval == -1) ? -1 : ((thread_retval == (DWORD) -1) ? -1 : (int) (retval + thread_retval));
 
       CloseHandle (thread_handles[i]);
     }


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