util/disk_cache: fix size subtraction on 32bit
Negating size_t on 32bit produces a 32bit result. This was effectively adding values close to UINT_MAX to the cache size (the files are usually small) instead of intended subtraction. Fixes 'make check' disk_cache failures on 32bit. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:

committed by
Timothy Arceri

parent
926bcacfd3
commit
61bbb25a08
@@ -603,7 +603,7 @@ evict_random_item(struct disk_cache *cache)
|
|||||||
free(dir_path);
|
free(dir_path);
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
p_atomic_add(cache->size, - size);
|
p_atomic_add(cache->size, - (uint64_t)size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +624,7 @@ evict_random_item(struct disk_cache *cache)
|
|||||||
free(dir_path);
|
free(dir_path);
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
p_atomic_add(cache->size, - size);
|
p_atomic_add(cache->size, - (uint64_t)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -646,7 +646,7 @@ disk_cache_remove(struct disk_cache *cache, const cache_key key)
|
|||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
if (sb.st_size)
|
if (sb.st_size)
|
||||||
p_atomic_add(cache->size, - sb.st_size);
|
p_atomic_add(cache->size, - (uint64_t)sb.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From the zlib docs:
|
/* From the zlib docs:
|
||||||
|
Reference in New Issue
Block a user