Commit | Line | Data |
---|---|---|
165d4554 LF |
1 | Fix a test failure when building for 32 bit architectures: |
2 | ||
3 | http://lists.gnu.org/archive/html/guix-devel/2017-04/msg00381.html | |
4 | ||
5 | Patch copied from upstream source repository: | |
6 | ||
7 | https://cgit.freedesktop.org/mesa/mesa/commit/?id=61bbb25a080e48a8ca897ba7f6e73cc6a8e9b5b8 | |
8 | ||
9 | From 61bbb25a080e48a8ca897ba7f6e73cc6a8e9b5b8 Mon Sep 17 00:00:00 2001 | |
10 | From: Grazvydas Ignotas <notasas@gmail.com> | |
11 | Date: Thu, 9 Mar 2017 02:54:53 +0200 | |
12 | Subject: [PATCH] util/disk_cache: fix size subtraction on 32bit | |
13 | ||
14 | Negating size_t on 32bit produces a 32bit result. This was effectively | |
15 | adding values close to UINT_MAX to the cache size (the files are usually | |
16 | small) instead of intended subtraction. | |
17 | Fixes 'make check' disk_cache failures on 32bit. | |
18 | ||
19 | Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> | |
20 | Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> | |
21 | --- | |
22 | src/util/disk_cache.c | 6 +++--- | |
23 | 1 file changed, 3 insertions(+), 3 deletions(-) | |
24 | ||
25 | diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c | |
26 | index 5470688df3..facdcecf7c 100644 | |
27 | --- a/src/util/disk_cache.c | |
28 | +++ b/src/util/disk_cache.c | |
29 | @@ -603,7 +603,7 @@ evict_random_item(struct disk_cache *cache) | |
30 | free(dir_path); | |
31 | ||
32 | if (size) { | |
33 | - p_atomic_add(cache->size, - size); | |
34 | + p_atomic_add(cache->size, - (uint64_t)size); | |
35 | return; | |
36 | } | |
37 | ||
38 | @@ -624,7 +624,7 @@ evict_random_item(struct disk_cache *cache) | |
39 | free(dir_path); | |
40 | ||
41 | if (size) | |
42 | - p_atomic_add(cache->size, - size); | |
43 | + p_atomic_add(cache->size, - (uint64_t)size); | |
44 | } | |
45 | ||
46 | void | |
47 | #@@ -646,7 +646,7 @@ disk_cache_remove(struct disk_cache *cache, const cache_key key) | |
48 | # free(filename); | |
49 | # | |
50 | # if (sb.st_size) | |
51 | #- p_atomic_add(cache->size, - sb.st_size); | |
52 | #+ p_atomic_add(cache->size, - (uint64_t)sb.st_size); | |
53 | # } | |
54 | # | |
55 | # /* From the zlib docs: | |
56 | -- | |
57 | 2.12.2 | |
58 |