@@ -36,14 +36,14 @@ static inline int equeue_tickdiff(unsigned a, unsigned b)
3636static inline int equeue_clampdiff (unsigned a , unsigned b )
3737{
3838 int diff = equeue_tickdiff (a , b );
39- return ~( diff >> ( 8 * sizeof ( int ) -1 )) & diff ;
39+ return diff > 0 ? diff : 0 ;
4040}
4141
4242// Increment the unique id in an event, hiding the event from cancel
4343static inline void equeue_incid (equeue_t * q , struct equeue_event * e )
4444{
4545 e -> id += 1 ;
46- if ((e -> id << q -> npw2 ) == 0 ) {
46+ if ((( unsigned ) e -> id << q -> npw2 ) == 0 ) {
4747 e -> id = 1 ;
4848 }
4949}
@@ -280,7 +280,7 @@ void equeue_enqueue(equeue_t *q, struct equeue_event *e, unsigned tick)
280280static int equeue_event_id (equeue_t * q , struct equeue_event * e )
281281{
282282 // 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 );
284284}
285285
286286static 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)
319319{
320320 // decode event from unique id and check that the local id matches
321321 struct equeue_event * e = (struct equeue_event * )
322- & q -> buffer [id & ((1 << q -> npw2 ) - 1 )];
322+ & q -> buffer [id & ((1u << q -> npw2 ) - 1u )];
323323
324324 equeue_mutex_lock (& q -> queuelock );
325- if (e -> id != id >> q -> npw2 ) {
325+ if (e -> id != ( unsigned ) id >> q -> npw2 ) {
326326 equeue_mutex_unlock (& q -> queuelock );
327327 return 0 ;
328328 }
@@ -447,10 +447,10 @@ int equeue_timeleft(equeue_t *q, int id)
447447
448448 // decode event from unique id and check that the local id matches
449449 struct equeue_event * e = (struct equeue_event * )
450- & q -> buffer [id & ((1 << q -> npw2 ) - 1 )];
450+ & q -> buffer [id & ((1u << q -> npw2 ) - 1u )];
451451
452452 equeue_mutex_lock (& q -> queuelock );
453- if (e -> id == id >> q -> npw2 ) {
453+ if (e -> id == ( unsigned ) id >> q -> npw2 ) {
454454 ret = equeue_clampdiff (e -> target , equeue_tick ());
455455 }
456456 equeue_mutex_unlock (& q -> queuelock );
0 commit comments