[glib: 17/25] Fixing signedness in glib/gthread-posix.c



commit 5dd02cc6f518555d1402ad06f99be784dd907899
Author: Emmanuel Fleury <emmanuel fleury u-bordeaux fr>
Date:   Mon Feb 4 16:36:11 2019 +0100

    Fixing signedness in glib/gthread-posix.c
    
    In file included from glib/glibconfig.h:9,
                     from glib/gtypes.h:32,
                     from glib/gatomic.h:27,
                     from glib/gthread.h:32,
                     from glib/gthread-posix.c:42:
    glib/gthread-posix.c: In function ‘g_system_thread_new’:
    glib/gmacros.h:348:26: error: comparison of integer expressions of different signedness: ‘long int’ and 
‘gulong’ {aka ‘long unsigned int’} [-Werror=sign-compare]
     #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
                              ^
    glib/gthread-posix.c:1169:22: note: in expansion of macro ‘MAX’
             stack_size = MAX (min_stack_size, stack_size);
                          ^~~
    glib/gmacros.h:348:35: error: operand of ?: changes signedness from ‘long int’ to ‘gulong’ {aka ‘long 
unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
     #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
                                       ^~~
    glib/gthread-posix.c:1169:22: note: in expansion of macro ‘MAX’
             stack_size = MAX (min_stack_size, stack_size);
                          ^~~

 glib/gthread-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 9c0b032e6..1e2fdb59a 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -1177,7 +1177,7 @@ g_system_thread_new (GThreadFunc   proxy,
 #ifdef _SC_THREAD_STACK_MIN
       long min_stack_size = sysconf (_SC_THREAD_STACK_MIN);
       if (min_stack_size >= 0)
-        stack_size = MAX (min_stack_size, stack_size);
+        stack_size = MAX ((gulong) min_stack_size, stack_size);
 #endif /* _SC_THREAD_STACK_MIN */
       /* No error check here, because some systems can't do it and
        * we simply don't want threads to fail because of that. */


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