@@ -36,14 +36,14 @@ static inline int equeue_tickdiff(unsigned a, unsigned b)
36
36
static inline int equeue_clampdiff (unsigned a , unsigned b )
37
37
{
38
38
int diff = equeue_tickdiff (a , b );
39
- return ~( diff >> ( 8 * sizeof ( int ) -1 )) & diff ;
39
+ return diff > 0 ? diff : 0 ;
40
40
}
41
41
42
42
// Increment the unique id in an event, hiding the event from cancel
43
43
static inline void equeue_incid (equeue_t * q , struct equeue_event * e )
44
44
{
45
45
e -> id += 1 ;
46
- if ((e -> id << q -> npw2 ) == 0 ) {
46
+ if ((( unsigned ) e -> id << q -> npw2 ) == 0 ) {
47
47
e -> id = 1 ;
48
48
}
49
49
}
@@ -280,7 +280,7 @@ void equeue_enqueue(equeue_t *q, struct equeue_event *e, unsigned tick)
280
280
static int equeue_event_id (equeue_t * q , struct equeue_event * e )
281
281
{
282
282
// setup event and hash local id with buffer offset for unique id
283
- return ((e -> id << q -> npw2 ) | ((unsigned char * )e - q -> buffer ) );
283
+ return ((unsigned ) e -> id << q -> npw2 ) | ((unsigned char * )e - q -> buffer );
284
284
}
285
285
286
286
static struct equeue_event * equeue_unqueue_by_address (equeue_t * q , struct equeue_event * e )
@@ -319,10 +319,10 @@ static struct equeue_event *equeue_unqueue_by_id(equeue_t *q, int id)
319
319
{
320
320
// decode event from unique id and check that the local id matches
321
321
struct equeue_event * e = (struct equeue_event * )
322
- & q -> buffer [id & ((1 << q -> npw2 ) - 1 )];
322
+ & q -> buffer [id & ((1u << q -> npw2 ) - 1u )];
323
323
324
324
equeue_mutex_lock (& q -> queuelock );
325
- if (e -> id != id >> q -> npw2 ) {
325
+ if (e -> id != ( unsigned ) id >> q -> npw2 ) {
326
326
equeue_mutex_unlock (& q -> queuelock );
327
327
return 0 ;
328
328
}
@@ -447,10 +447,10 @@ int equeue_timeleft(equeue_t *q, int id)
447
447
448
448
// decode event from unique id and check that the local id matches
449
449
struct equeue_event * e = (struct equeue_event * )
450
- & q -> buffer [id & ((1 << q -> npw2 ) - 1 )];
450
+ & q -> buffer [id & ((1u << q -> npw2 ) - 1u )];
451
451
452
452
equeue_mutex_lock (& q -> queuelock );
453
- if (e -> id == id >> q -> npw2 ) {
453
+ if (e -> id == ( unsigned ) id >> q -> npw2 ) {
454
454
ret = equeue_clampdiff (e -> target , equeue_tick ());
455
455
}
456
456
equeue_mutex_unlock (& q -> queuelock );
0 commit comments