summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_keycache.c11
-rw-r--r--mysys/my_seek.c1
2 files changed, 6 insertions, 6 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 87f136dbf81..af910678a1f 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -173,7 +173,7 @@ static void test_key_cache(KEY_CACHE *keycache,
#endif
#define KEYCACHE_HASH(f, pos) \
-(((ulong) ((pos) >> keycache->key_cache_shift)+ \
+(((ulong) ((pos) / keycache->key_cache_block_size) + \
(ulong) (f)) & (keycache->hash_entries-1))
#define FILE_HASH(f) ((uint) (f) & (CHANGED_BLOCKS_HASH-1))
@@ -329,7 +329,6 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->key_cache_mem_size= use_mem;
keycache->key_cache_block_size= key_cache_block_size;
- keycache->key_cache_shift= my_bit_log2(key_cache_block_size);
DBUG_PRINT("info", ("key_cache_block_size: %u",
key_cache_block_size));
@@ -352,7 +351,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) +
ALIGN_SIZE(sizeof(HASH_LINK*) *
keycache->hash_entries))) +
- ((ulong) blocks << keycache->key_cache_shift) > use_mem)
+ ((ulong) blocks * keycache->key_cache_block_size) > use_mem)
blocks--;
/* Allocate memory for cache page buffers */
if ((keycache->block_mem=
@@ -1807,7 +1806,7 @@ byte *key_cache_read(KEY_CACHE *keycache,
uint status;
int page_st;
- offset= (uint) (filepos & (keycache->key_cache_block_size-1));
+ offset= (uint) (filepos % keycache->key_cache_block_size);
/* Read data in key_cache_block_size increments */
do
{
@@ -1946,7 +1945,7 @@ int key_cache_insert(KEY_CACHE *keycache,
int error;
uint offset;
- offset= (uint) (filepos & (keycache->key_cache_block_size-1));
+ offset= (uint) (filepos % keycache->key_cache_block_size);
do
{
keycache_pthread_mutex_lock(&keycache->cache_lock);
@@ -2081,7 +2080,7 @@ int key_cache_write(KEY_CACHE *keycache,
int page_st;
uint offset;
- offset= (uint) (filepos & (keycache->key_cache_block_size-1));
+ offset= (uint) (filepos % keycache->key_cache_block_size);
do
{
keycache_pthread_mutex_lock(&keycache->cache_lock);
diff --git a/mysys/my_seek.c b/mysys/my_seek.c
index 3d415400aa2..5c1a6c44b6f 100644
--- a/mysys/my_seek.c
+++ b/mysys/my_seek.c
@@ -88,6 +88,7 @@ my_off_t my_tell(File fd, myf MyFlags __attribute__((unused)))
os_off_t pos;
DBUG_ENTER("my_tell");
DBUG_PRINT("my",("Fd: %d MyFlags: %d",fd, MyFlags));
+ DBUG_ASSERT(fd >= 0);
#ifdef HAVE_TELL
pos=tell(fd);
#else