Fixing signedness in glib/gthreadpool.c

glib/gthreadpool.c: In function ‘g_thread_pool_wait_for_new_pool’:
glib/gthreadpool.c:157:46: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’} [-Werror=sign-compare]
       if (g_atomic_int_get (&unused_threads) >= local_max_unused_threads)
                                              ^~
glib/gthreadpool.c: In function ‘g_thread_pool_wakeup_and_stop_all’:
glib/gthreadpool.c:836:17: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} [-Werror=sign-compare]
   for (i = 0; i < pool->num_threads; i++)
                 ^
This commit is contained in:
Emmanuel Fleury 2019-02-04 10:34:13 +01:00
parent 592d4369d4
commit 179dbbde14

View File

@ -91,7 +91,7 @@ struct _GRealThreadPool
GAsyncQueue *queue;
GCond cond;
gint max_threads;
gint num_threads;
guint num_threads;
gboolean running;
gboolean immediate;
gboolean waiting;
@ -154,7 +154,7 @@ g_thread_pool_wait_for_new_pool (void)
do
{
if (g_atomic_int_get (&unused_threads) >= local_max_unused_threads)
if ((guint) g_atomic_int_get (&unused_threads) >= local_max_unused_threads)
{
/* If this is a superfluous thread, stop it. */
pool = NULL;
@ -234,7 +234,7 @@ g_thread_pool_wait_for_new_task (GRealThreadPool *pool)
g_async_queue_length_unlocked (pool->queue) > 0))
{
/* This thread pool is still active. */
if (pool->num_threads > pool->max_threads && pool->max_threads != -1)
if (pool->max_threads != -1 && pool->num_threads > (guint) pool->max_threads)
{
/* This is a superfluous thread, so it goes to the global pool. */
DEBUG_MSG (("superfluous thread %p in pool %p.",
@ -340,7 +340,7 @@ g_thread_pool_thread_proxy (gpointer data)
* queue, wakeup the remaining threads.
*/
if (g_async_queue_length_unlocked (pool->queue) ==
- pool->num_threads)
(gint) -pool->num_threads)
g_thread_pool_wakeup_and_stop_all (pool);
}
}
@ -386,7 +386,7 @@ g_thread_pool_start_thread (GRealThreadPool *pool,
{
gboolean success = FALSE;
if (pool->num_threads >= pool->max_threads && pool->max_threads != -1)
if (pool->max_threads != -1 && pool->num_threads >= (guint) pool->max_threads)
/* Enough threads are already running */
return TRUE;
@ -504,7 +504,7 @@ g_thread_pool_new (GFunc func,
{
g_async_queue_lock (retval->queue);
while (retval->num_threads < retval->max_threads)
while (retval->num_threads < (guint) retval->max_threads)
{
GError *local_error = NULL;
@ -777,12 +777,12 @@ g_thread_pool_free (GThreadPool *pool,
if (wait_)
{
while (g_async_queue_length_unlocked (real->queue) != -real->num_threads &&
while (g_async_queue_length_unlocked (real->queue) != (gint) -real->num_threads &&
!(immediate && real->num_threads == 0))
g_cond_wait (&real->cond, _g_async_queue_get_mutex (real->queue));
}
if (immediate || g_async_queue_length_unlocked (real->queue) == -real->num_threads)
if (immediate || g_async_queue_length_unlocked (real->queue) == (gint) -real->num_threads)
{
/* No thread is currently doing something (and nothing is left
* to process in the queue)