[glib: 11/25] Fixing signedness in glib/gthreadpool.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 11/25] Fixing signedness in glib/gthreadpool.c
- Date: Tue, 19 Mar 2019 11:03:46 +0000 (UTC)
commit 179dbbde14ff0c7cdc39dc579187921b5d401eeb
Author: Emmanuel Fleury <emmanuel fleury u-bordeaux fr>
Date: Mon Feb 4 10:34:13 2019 +0100
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++)
^
glib/gthreadpool.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/glib/gthreadpool.c b/glib/gthreadpool.c
index a1fbda671..0a5f7518a 100644
--- a/glib/gthreadpool.c
+++ b/glib/gthreadpool.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]