Fixing signedness warning in glib/gslice.c

In file included from glib/glibconfig.h:9,
                 from glib/gslice.c:20:
glib/gslice.c: In function ‘magazine_cache_trim’:
glib/gmacros.h:354:25: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
 #define ABS(a)    (((a) < 0) ? -(a) : (a))
                         ^
glib/gslice.c:643:10: note: in expansion of macro ‘ABS’
   while (ABS (stamp - magazine_chain_uint_stamp (current)) >= allocator->config.working_set_msecs)
          ^~~
This commit is contained in:
Emmanuel Fleury 2019-02-23 09:56:57 +01:00
parent e9f57495c6
commit fad04d2e18

View File

@ -640,7 +640,10 @@ magazine_cache_trim (Allocator *allocator,
/* trim magazine cache from tail */
ChunkLink *current = magazine_chain_prev (allocator->magazines[ix]);
ChunkLink *trash = NULL;
while (ABS (stamp - magazine_chain_uint_stamp (current)) >= allocator->config.working_set_msecs)
while ((stamp >= magazine_chain_uint_stamp (current) &&
stamp - magazine_chain_uint_stamp (current) >= allocator->config.working_set_msecs) ||
(stamp <= magazine_chain_uint_stamp (current) &&
magazine_chain_uint_stamp (current) - stamp >= allocator->config.working_set_msecs))
{
/* unlink */
ChunkLink *prev = magazine_chain_prev (current);