Browse code

add some casts

Nat! authored on 12-07-2016 15:52:05
Showing 2 changed files
... ...
@@ -91,7 +91,7 @@ static struct _mulle_concurrent_hashmapstorage *
91 91
       struct _mulle_concurrent_hashvaluepair   *sentinel;
92 92
       
93 93
       q        = p->entries;
94
-      sentinel = &p->entries[ p->mask];
94
+      sentinel = &p->entries[ (unsigned int) p->mask];
95 95
       while( q <= sentinel)
96 96
       {
97 97
          q->hash  = MULLE_CONCURRENT_NO_HASH;
... ...
@@ -110,7 +110,7 @@ static unsigned int
110 110
    unsigned int   size;
111 111
    unsigned int   max;
112 112
    
113
-   size = p->mask + 1;
113
+   size = (unsigned int) p->mask + 1;
114 114
    max  = size - (size >> 1);
115 115
    return( max);
116 116
 }
... ...
@@ -124,11 +124,11 @@ static void   *_mulle_concurrent_hashmapstorage_lookup( struct _mulle_concurrent
124 124
    unsigned int                             sentinel;
125 125
    
126 126
    index    = (unsigned int) hash;
127
-   sentinel = (unsigned int) (index + p->mask + 1);
127
+   sentinel = index + (unsigned int) p->mask + 1;
128 128
 
129 129
    for(;;)
130 130
    {
131
-      entry = &p->entries[ index & p->mask];
131
+      entry = &p->entries[ index & (unsigned int) p->mask];
132 132
 
133 133
       if( entry->hash == MULLE_CONCURRENT_NO_HASH)
134 134
          return( MULLE_CONCURRENT_NO_POINTER);
... ...
@@ -150,7 +150,7 @@ static struct _mulle_concurrent_hashvaluepair  *
150 150
    struct _mulle_concurrent_hashvaluepair   *sentinel;
151 151
    
152 152
    entry    = &p->entries[ *index];
153
-   sentinel = &p->entries[ p->mask + 1];
153
+   sentinel = &p->entries[ (unsigned int) p->mask + 1];
154 154
 
155 155
    while( entry < sentinel)
156 156
    {
... ...
@@ -187,11 +187,11 @@ static int   _mulle_concurrent_hashmapstorage_insert( struct _mulle_concurrent_h
187 187
    assert( value != MULLE_CONCURRENT_NO_POINTER && value != MULLE_CONCURRENT_INVALID_POINTER);
188 188
 
189 189
    index    = (unsigned int) hash;
190
-   sentinel = (unsigned int) (index + p->mask + 1);
190
+   sentinel = (unsigned int) (index + (unsigned int) p->mask + 1);
191 191
    
192 192
    for(;;)
193 193
    {
194
-      entry = &p->entries[ index & p->mask];
194
+      entry = &p->entries[ index & (unsigned int) p->mask];
195 195
 
196 196
       if( entry->hash == MULLE_CONCURRENT_NO_HASH || entry->hash == hash)
197 197
       {
... ...
@@ -231,11 +231,11 @@ static int   _mulle_concurrent_hashmapstorage_put( struct _mulle_concurrent_hash
231 231
    assert( value);
232 232
 
233 233
    index    = (unsigned int) hash;
234
-   sentinel = (unsigned int) (index + p->mask + 1);
234
+   sentinel = (unsigned int) (index + (unsigned int) p->mask + 1);
235 235
    
236 236
    for(;;)
237 237
    {
238
-      entry = &p->entries[ index & p->mask];
238
+      entry = &p->entries[ index & (unsigned int) p->mask];
239 239
 
240 240
       if( entry->hash == hash)
241 241
       {
... ...
@@ -283,10 +283,10 @@ static int   _mulle_concurrent_hashmapstorage_remove( struct _mulle_concurrent_h
283 283
    unsigned int                             sentinel;
284 284
    
285 285
    index    = (unsigned int) hash;
286
-   sentinel = (unsigned int) (hash + p->mask + 1);
286
+   sentinel = index + (unsigned int) p->mask + 1;
287 287
    for(;;)
288 288
    {
289
-      entry  = &p->entries[ index & p->mask];
289
+      entry  = &p->entries[ index & (unsigned int) p->mask];
290 290
 
291 291
       if( entry->hash == hash)
292 292
       {
... ...
@@ -412,7 +412,7 @@ static int  _mulle_concurrent_hashmap_migrate_storage( struct mulle_concurrent_h
412 412
    if( q == p)
413 413
    {
414 414
       // acquire new storage
415
-      alloced = _mulle_concurrent_alloc_hashmapstorage( (p->mask + 1) * 2, map->allocator);
415
+      alloced = _mulle_concurrent_alloc_hashmapstorage( ((unsigned int) p->mask + 1) * 2, map->allocator);
416 416
       if( ! alloced)
417 417
          return( -1);
418 418
       
... ...
@@ -476,7 +476,7 @@ static int   _mulle_concurrent_hashmap_search_next( struct mulle_concurrent_hash
476 476
    
477 477
 retry:
478 478
    p = _mulle_atomic_pointer_read( &map->storage.pointer);
479
-   if( *expect_mask && p->mask != *expect_mask)
479
+   if( *expect_mask && (unsigned int) p->mask != *expect_mask)
480 480
       return( -ECANCELED);
481 481
    
482 482
    for(;;)
... ...
@@ -503,7 +503,7 @@ retry:
503 503
       *p_value = value;
504 504
    
505 505
    if( ! *expect_mask)
506
-      *expect_mask = p->mask;
506
+      *expect_mask = (unsigned int) p->mask;
507 507
    
508 508
    return( 1);
509 509
 }
... ...
@@ -577,7 +577,7 @@ unsigned int  _mulle_concurrent_hashmap_get_size( struct mulle_concurrent_hashma
577 577
    struct _mulle_concurrent_hashmapstorage   *p;
578 578
    
579 579
    p = _mulle_atomic_pointer_read( &map->storage.pointer);
580
-   return( p->mask + 1);
580
+   return( (unsigned int) p->mask + 1);
581 581
 }
582 582
 
583 583
 
... ...
@@ -88,7 +88,7 @@ static struct _mulle_concurrent_pointerarraystorage *
88 88
       mulle_atomic_pointer_t   *sentinel;
89 89
       
90 90
       q        = p->entries;
91
-      sentinel = &p->entries[ p->size];
91
+      sentinel = &p->entries[ (unsigned int) p->size];
92 92
       while( q < sentinel)
93 93
       {
94 94
          _mulle_atomic_pointer_nonatomic_write( q, MULLE_CONCURRENT_NO_POINTER);
... ...
@@ -127,7 +127,7 @@ static int   _mulle_concurrent_pointerarraystorage_add( struct _mulle_concurrent
127 127
    for(;;)
128 128
    {
129 129
       i = (unsigned int) (uintptr_t) _mulle_atomic_pointer_read( &p->n);
130
-      if( i >= p->size)
130
+      if( i >= (unsigned int) p->size)
131 131
          return( ENOSPC);
132 132
 
133 133
       found = __mulle_atomic_pointer_compare_and_swap( &p->entries[ i], value, MULLE_CONCURRENT_NO_POINTER);
... ...
@@ -230,7 +230,7 @@ static int  _mulle_concurrent_pointerarray_migrate_storage( struct mulle_concurr
230 230
    
231 231
    if( q == p)
232 232
    {
233
-      alloced = _mulle_concurrent_alloc_pointerarraystorage( p->size * 2, array->allocator);
233
+      alloced = _mulle_concurrent_alloc_pointerarraystorage( (unsigned int) p->size * 2, array->allocator);
234 234
       if( ! alloced)
235 235
          return( -1);
236 236
 
... ...
@@ -308,7 +308,7 @@ unsigned int  _mulle_concurrent_pointerarray_get_size( struct mulle_concurrent_p
308 308
    struct _mulle_concurrent_pointerarraystorage   *p;
309 309
    
310 310
    p = _mulle_atomic_pointer_read( &array->storage.pointer);
311
-   return( p->size);
311
+   return( (unsigned int) p->size);
312 312
 }
313 313
 
314 314