You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/03/04 17:37:45 UTC
svn commit: r1574128 -
/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
Author: breser
Date: Tue Mar 4 16:37:45 2014
New Revision: 1574128
URL: http://svn.apache.org/r1574128
Log:
Fix compiler errors regarding index values for membuffer cache.
The maximum entries in a membuffer cache is limited to the max value of an
apr_uint32_t. But does pointer arithmatic to calculate indexes into the
cache. On 64-bit platforms the pointers are going to be 64-bits wide, so
the calculation will be 64-bits wide. The results will stay within the
range of the apr_uint32_t so it's safe to just cast these calculations.
* subversion/libsvn_subr/cache-membuffer.c
(free_spare_group): Cast to apr_uint32_t when calculating first_spare_group.
(drop_entry): Cast to apr_uint32_t when calculating last_in_group.
(find_entry): Cast to apr_uint32_t when calculating previous and next on
group headers.
Modified:
subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
Modified: subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c?rev=1574128&r1=1574127&r2=1574128&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Tue Mar 4 16:37:45 2014
@@ -811,7 +811,7 @@ free_spare_group(svn_membuffer_t *cache,
/* add to chain of spares */
group->header.next = cache->first_spare_group;
- cache->first_spare_group = group - cache->directory;
+ cache->first_spare_group = (apr_uint32_t) (group - cache->directory);
}
/* Follow the group chain from GROUP in CACHE to its end and return the last
@@ -966,8 +966,8 @@ drop_entry(svn_membuffer_t *cache, entry
entry_group_t *last_group
= last_group_in_chain(cache, &cache->directory[group_index]);
apr_uint32_t last_in_group
- = (last_group - cache->directory) * GROUP_SIZE
- + last_group->header.used - 1;
+ = (apr_uint32_t) ((last_group - cache->directory) * GROUP_SIZE
+ + last_group->header.used - 1);
cache_level_t *level = get_cache_level(cache, entry);
@@ -1204,9 +1204,11 @@ find_entry(svn_membuffer_t *cache,
/* chain groups
*/
new_group->header.chain_length = group->header.chain_length + 1;
- new_group->header.previous = group - cache->directory;
+ new_group->header.previous = (apr_uint32_t) (group -
+ cache->directory);
new_group->header.next = NO_INDEX;
- group->header.next = new_group - cache->directory;
+ group->header.next = (apr_uint32_t) (new_group -
+ cache->directory);
group = new_group;
}
}