Commit a3af9a78 authored by Michael Widenius's avatar Michael Widenius

Fixed some wrong usage of my_bool

Fixed compiler warning
Ensure that pagecache returns correct error number


storage/maria/ma_pagecache.c:
  Ensure that block->error contain error code from my_errno (not return value from pread/pwrite)
  Went through usage of my_pread/my_pwrite and ensured that result was threated correctly
  Fixed some wrong usage of my_bool
parent 8fef39de
...@@ -593,16 +593,16 @@ extern my_bool translog_flush(TRANSLOG_ADDRESS lsn); ...@@ -593,16 +593,16 @@ extern my_bool translog_flush(TRANSLOG_ADDRESS lsn);
RETURN RETURN
0 - OK 0 - OK
!=0 - Error 1 - Error
*/ */
static uint pagecache_fwrite(PAGECACHE *pagecache, static my_bool pagecache_fwrite(PAGECACHE *pagecache,
PAGECACHE_FILE *filedesc, PAGECACHE_FILE *filedesc,
uchar *buffer, uchar *buffer,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
enum pagecache_page_type type enum pagecache_page_type type
__attribute__((unused)), __attribute__((unused)),
myf flags) myf flags)
{ {
DBUG_ENTER("pagecache_fwrite"); DBUG_ENTER("pagecache_fwrite");
DBUG_ASSERT(type != PAGECACHE_READ_UNKNOWN_PAGE); DBUG_ASSERT(type != PAGECACHE_READ_UNKNOWN_PAGE);
...@@ -2069,7 +2069,7 @@ static PAGECACHE_BLOCK_LINK *find_block(PAGECACHE *pagecache, ...@@ -2069,7 +2069,7 @@ static PAGECACHE_BLOCK_LINK *find_block(PAGECACHE *pagecache,
(my_bool)(block->hash_link ? 1 : 0)); (my_bool)(block->hash_link ? 1 : 0));
PCBLOCK_INFO(block); PCBLOCK_INFO(block);
block->status= error ? PCBLOCK_ERROR : 0; block->status= error ? PCBLOCK_ERROR : 0;
block->error= error; block->error= (int16) my_errno;
#ifndef DBUG_OFF #ifndef DBUG_OFF
block->type= PAGECACHE_EMPTY_PAGE; block->type= PAGECACHE_EMPTY_PAGE;
if (error) if (error)
...@@ -2608,7 +2608,7 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2608,7 +2608,7 @@ static void read_block(PAGECACHE *pagecache,
if (error) if (error)
{ {
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
block->error= error; block->error= (int16) my_errno;
my_debug_put_break_here(); my_debug_put_break_here();
} }
else else
...@@ -2621,7 +2621,7 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2621,7 +2621,7 @@ static void read_block(PAGECACHE *pagecache,
{ {
DBUG_PRINT("error", ("read callback problem")); DBUG_PRINT("error", ("read callback problem"));
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
block->error= my_errno; block->error= (int16) my_errno;
my_debug_put_break_here(); my_debug_put_break_here();
} }
} }
...@@ -3111,7 +3111,7 @@ uchar *pagecache_read(PAGECACHE *pagecache, ...@@ -3111,7 +3111,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
PAGECACHE_BLOCK_LINK **page_link) PAGECACHE_BLOCK_LINK **page_link)
{ {
int error= 0; my_bool error= 0;
enum pagecache_page_pin pin= lock_to_pin[test(buff==0)][lock]; enum pagecache_page_pin pin= lock_to_pin[test(buff==0)][lock];
PAGECACHE_BLOCK_LINK *fake_link; PAGECACHE_BLOCK_LINK *fake_link;
my_bool reg_request; my_bool reg_request;
...@@ -3292,7 +3292,7 @@ static my_bool pagecache_delete_internal(PAGECACHE *pagecache, ...@@ -3292,7 +3292,7 @@ static my_bool pagecache_delete_internal(PAGECACHE *pagecache,
PAGECACHE_HASH_LINK *page_link, PAGECACHE_HASH_LINK *page_link,
my_bool flush) my_bool flush)
{ {
int error= 0; my_bool error= 0;
if (block->status & PCBLOCK_CHANGED) if (block->status & PCBLOCK_CHANGED)
{ {
if (flush) if (flush)
...@@ -3319,7 +3319,7 @@ static my_bool pagecache_delete_internal(PAGECACHE *pagecache, ...@@ -3319,7 +3319,7 @@ static my_bool pagecache_delete_internal(PAGECACHE *pagecache,
if (error) if (error)
{ {
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
block->error= error; block->error= (int16) my_errno;
my_debug_put_break_here(); my_debug_put_break_here();
goto err; goto err;
} }
...@@ -3368,7 +3368,7 @@ my_bool pagecache_delete_by_link(PAGECACHE *pagecache, ...@@ -3368,7 +3368,7 @@ my_bool pagecache_delete_by_link(PAGECACHE *pagecache,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
my_bool flush) my_bool flush)
{ {
int error= 0; my_bool error= 0;
enum pagecache_page_pin pin= PAGECACHE_PIN_LEFT_PINNED; enum pagecache_page_pin pin= PAGECACHE_PIN_LEFT_PINNED;
DBUG_ENTER("pagecache_delete_by_link"); DBUG_ENTER("pagecache_delete_by_link");
DBUG_PRINT("enter", ("fd: %d block 0x%lx %s %s", DBUG_PRINT("enter", ("fd: %d block 0x%lx %s %s",
...@@ -3467,7 +3467,7 @@ my_bool pagecache_delete(PAGECACHE *pagecache, ...@@ -3467,7 +3467,7 @@ my_bool pagecache_delete(PAGECACHE *pagecache,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
my_bool flush) my_bool flush)
{ {
int error= 0; my_bool error= 0;
enum pagecache_page_pin pin= lock_to_pin[0][lock]; enum pagecache_page_pin pin= lock_to_pin[0][lock];
DBUG_ENTER("pagecache_delete"); DBUG_ENTER("pagecache_delete");
DBUG_PRINT("enter", ("fd: %u page: %lu %s %s", DBUG_PRINT("enter", ("fd: %u page: %lu %s %s",
...@@ -3655,7 +3655,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3655,7 +3655,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
{ {
PAGECACHE_BLOCK_LINK *block= NULL; PAGECACHE_BLOCK_LINK *block= NULL;
PAGECACHE_BLOCK_LINK *fake_link; PAGECACHE_BLOCK_LINK *fake_link;
int error= 0; my_bool error= 0;
int need_lock_change= write_lock_change_table[lock].need_lock_change; int need_lock_change= write_lock_change_table[lock].need_lock_change;
my_bool reg_request; my_bool reg_request;
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -3778,7 +3778,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3778,7 +3778,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
{ {
DBUG_PRINT("error", ("read callback problem")); DBUG_PRINT("error", ("read callback problem"));
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
block->error= my_errno; block->error= (int16) my_errno;
my_debug_put_break_here(); my_debug_put_break_here();
} }
KEYCACHE_DBUG_PRINT("key_cache_insert", KEYCACHE_DBUG_PRINT("key_cache_insert",
...@@ -3868,10 +3868,10 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3868,10 +3868,10 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
uchar *page_buffer= (uchar *) alloca(pagecache->block_size); uchar *page_buffer= (uchar *) alloca(pagecache->block_size);
pagecache->global_cache_read++; pagecache->global_cache_read++;
if ((error= pagecache_fread(pagecache, file, if ((error= (pagecache_fread(pagecache, file,
page_buffer, page_buffer,
pageno, pageno,
pagecache->readwrite_flags))) pagecache->readwrite_flags) != 0)))
goto end; goto end;
if ((file->read_callback)(page_buffer, pageno, file->callback_data)) if ((file->read_callback)(page_buffer, pageno, file->callback_data))
{ {
...@@ -3995,7 +3995,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -3995,7 +3995,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
int *first_errno) int *first_errno)
{ {
int rc= PCFLUSH_OK; int rc= PCFLUSH_OK;
int error; my_bool error;
uint count= (uint) (end-cache); uint count= (uint) (end-cache);
DBUG_ENTER("flush_cached_blocks"); DBUG_ENTER("flush_cached_blocks");
*first_errno= 0; *first_errno= 0;
...@@ -4075,7 +4075,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -4075,7 +4075,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
if (error) if (error)
{ {
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
block->error= error; block->error= (int16) my_errno;
my_debug_put_break_here(); my_debug_put_break_here();
if (!*first_errno) if (!*first_errno)
*first_errno= my_errno ? my_errno : -1; *first_errno= my_errno ? my_errno : -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment