Commit 374850dc authored by unknown's avatar unknown

InnoDB: Remove warnings detected by GCC 4.0.0


innobase/fsp/fsp0fsp.c:
  Declare "first" in the scope where it is used, and add dummy return
  statement after ut_error to silence compiler warning.
innobase/include/dyn0dyn.h:
  Add const qualifier to dyn_push_string().
innobase/include/dyn0dyn.ic:
  dyn_push_string(): Add const qualifier to str;
  remove intermediate assignment.
innobase/include/mtr0log.h:
  mlog_write_string(), mlog_catenate_string(): Add const to str
innobase/log/log0log.c:
  Eliminate variables new_oldest and do_preflush in order to avoid
  warnings about possibly uninitialized variables.
  (new_oldest will now be declared in the scope of usage,
  and do_preflush == (advance != 0).)
innobase/log/log0recv.c:
  Remove warnings about uninitialized variables.
  Add UNIV_UNLIKELY() hints.
innobase/mtr/mtr0log.c:
  mlog_write_string(), mlog_catenate_string(): Add const to str
  mlog_write_string(): Add UNIV_UNLIKELY hints to assertion-like tests
innobase/row/row0sel.c:
  Remove warning about possibly uninitialized variable.
  (Always initialize *out_rec.)
parent 67b538cc
...@@ -2325,7 +2325,6 @@ fseg_alloc_free_page_low( ...@@ -2325,7 +2325,6 @@ fseg_alloc_free_page_low(
dulint seg_id; dulint seg_id;
ulint used; ulint used;
ulint reserved; ulint reserved;
fil_addr_t first;
xdes_t* descr; /* extent of the hinted page */ xdes_t* descr; /* extent of the hinted page */
ulint ret_page; /* the allocated page offset, FIL_NULL ulint ret_page; /* the allocated page offset, FIL_NULL
if could not be allocated */ if could not be allocated */
...@@ -2428,6 +2427,8 @@ fseg_alloc_free_page_low( ...@@ -2428,6 +2427,8 @@ fseg_alloc_free_page_low(
} else if (reserved - used > 0) { } else if (reserved - used > 0) {
/* 5. We take any unused page from the segment /* 5. We take any unused page from the segment
==============================================*/ ==============================================*/
fil_addr_t first;
if (flst_get_len(seg_inode + FSEG_NOT_FULL, mtr) > 0) { if (flst_get_len(seg_inode + FSEG_NOT_FULL, mtr) > 0) {
first = flst_get_first(seg_inode + FSEG_NOT_FULL, first = flst_get_first(seg_inode + FSEG_NOT_FULL,
mtr); mtr);
...@@ -2435,6 +2436,7 @@ fseg_alloc_free_page_low( ...@@ -2435,6 +2436,7 @@ fseg_alloc_free_page_low(
first = flst_get_first(seg_inode + FSEG_FREE, mtr); first = flst_get_first(seg_inode + FSEG_FREE, mtr);
} else { } else {
ut_error; ut_error;
return(FIL_NULL);
} }
ret_descr = xdes_lst_get_descriptor(space, first, mtr); ret_descr = xdes_lst_get_descriptor(space, first, mtr);
......
...@@ -132,7 +132,7 @@ void ...@@ -132,7 +132,7 @@ void
dyn_push_string( dyn_push_string(
/*============*/ /*============*/
dyn_array_t* arr, /* in: dyn array */ dyn_array_t* arr, /* in: dyn array */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len); /* in: string length */ ulint len); /* in: string length */
/*#################################################################*/ /*#################################################################*/
......
...@@ -324,10 +324,9 @@ void ...@@ -324,10 +324,9 @@ void
dyn_push_string( dyn_push_string(
/*============*/ /*============*/
dyn_array_t* arr, /* in: dyn array */ dyn_array_t* arr, /* in: dyn array */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len) /* in: string length */ ulint len) /* in: string length */
{ {
byte* ptr;
ulint n_copied; ulint n_copied;
while (len > 0) { while (len > 0) {
...@@ -337,9 +336,7 @@ dyn_push_string( ...@@ -337,9 +336,7 @@ dyn_push_string(
n_copied = len; n_copied = len;
} }
ptr = (byte*) dyn_array_push(arr, n_copied); memcpy(dyn_array_push(arr, n_copied), str, n_copied);
ut_memcpy(ptr, str, n_copied);
str += n_copied; str += n_copied;
len -= n_copied; len -= n_copied;
......
...@@ -41,10 +41,10 @@ corresponding log record to the mini-transaction log. */ ...@@ -41,10 +41,10 @@ corresponding log record to the mini-transaction log. */
void void
mlog_write_string( mlog_write_string(
/*==============*/ /*==============*/
byte* ptr, /* in: pointer where to write */ byte* ptr, /* in: pointer where to write */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len, /* in: string length */ ulint len, /* in: string length */
mtr_t* mtr); /* in: mini-transaction handle */ mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************ /************************************************************
Writes initial part of a log record consisting of one-byte item Writes initial part of a log record consisting of one-byte item
type and four-byte space and page numbers. */ type and four-byte space and page numbers. */
...@@ -85,9 +85,9 @@ Catenates n bytes to the mtr log. */ ...@@ -85,9 +85,9 @@ Catenates n bytes to the mtr log. */
void void
mlog_catenate_string( mlog_catenate_string(
/*=================*/ /*=================*/
mtr_t* mtr, /* in: mtr */ mtr_t* mtr, /* in: mtr */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len); /* in: string length */ ulint len); /* in: string length */
/************************************************************ /************************************************************
Catenates a compressed ulint to mlog. */ Catenates a compressed ulint to mlog. */
UNIV_INLINE UNIV_INLINE
......
...@@ -2038,8 +2038,6 @@ log_checkpoint_margin(void) ...@@ -2038,8 +2038,6 @@ log_checkpoint_margin(void)
ulint checkpoint_age; ulint checkpoint_age;
ulint advance; ulint advance;
dulint oldest_lsn; dulint oldest_lsn;
dulint new_oldest;
ibool do_preflush;
ibool sync; ibool sync;
ibool checkpoint_sync; ibool checkpoint_sync;
ibool do_checkpoint; ibool do_checkpoint;
...@@ -2047,7 +2045,6 @@ log_checkpoint_margin(void) ...@@ -2047,7 +2045,6 @@ log_checkpoint_margin(void)
loop: loop:
sync = FALSE; sync = FALSE;
checkpoint_sync = FALSE; checkpoint_sync = FALSE;
do_preflush = FALSE;
do_checkpoint = FALSE; do_checkpoint = FALSE;
mutex_enter(&(log->mutex)); mutex_enter(&(log->mutex));
...@@ -2067,21 +2064,13 @@ log_checkpoint_margin(void) ...@@ -2067,21 +2064,13 @@ log_checkpoint_margin(void)
/* A flush is urgent: we have to do a synchronous preflush */ /* A flush is urgent: we have to do a synchronous preflush */
sync = TRUE; sync = TRUE;
advance = 2 * (age - log->max_modified_age_async);
advance = 2 * (age - log->max_modified_age_sync);
new_oldest = ut_dulint_add(oldest_lsn, advance);
do_preflush = TRUE;
} else if (age > log->max_modified_age_async) { } else if (age > log->max_modified_age_async) {
/* A flush is not urgent: we do an asynchronous preflush */ /* A flush is not urgent: we do an asynchronous preflush */
advance = age - log->max_modified_age_async; advance = age - log->max_modified_age_async;
} else {
new_oldest = ut_dulint_add(oldest_lsn, advance); advance = 0;
do_preflush = TRUE;
} }
checkpoint_age = ut_dulint_minus(log->lsn, log->last_checkpoint_lsn); checkpoint_age = ut_dulint_minus(log->lsn, log->last_checkpoint_lsn);
...@@ -2105,7 +2094,9 @@ log_checkpoint_margin(void) ...@@ -2105,7 +2094,9 @@ log_checkpoint_margin(void)
mutex_exit(&(log->mutex)); mutex_exit(&(log->mutex));
if (do_preflush) { if (advance) {
dulint new_oldest = ut_dulint_add(oldest_lsn, advance);
success = log_preflush_pool_modified_pages(new_oldest, sync); success = log_preflush_pool_modified_pages(new_oldest, sync);
/* If the flush succeeded, this thread has done its part /* If the flush succeeded, this thread has done its part
......
...@@ -543,7 +543,7 @@ recv_find_max_checkpoint( ...@@ -543,7 +543,7 @@ recv_find_max_checkpoint(
"InnoDB: to create the InnoDB data files, but log file creation failed.\n" "InnoDB: to create the InnoDB data files, but log file creation failed.\n"
"InnoDB: If that is the case, please refer to\n" "InnoDB: If that is the case, please refer to\n"
"InnoDB: http://dev.mysql.com/doc/mysql/en/Error_creating_InnoDB.html\n"); "InnoDB: http://dev.mysql.com/doc/mysql/en/Error_creating_InnoDB.html\n");
*max_field = 0;
return(DB_ERROR); return(DB_ERROR);
} }
...@@ -1818,25 +1818,25 @@ recv_parse_log_rec( ...@@ -1818,25 +1818,25 @@ recv_parse_log_rec(
new_ptr = mlog_parse_initial_log_record(ptr, end_ptr, type, space, new_ptr = mlog_parse_initial_log_record(ptr, end_ptr, type, space,
page_no); page_no);
if (!new_ptr) { *body = new_ptr;
if (UNIV_UNLIKELY(!new_ptr)) {
return(0); return(0);
} }
/* Check that page_no is sensible */ /* Check that page_no is sensible */
if (*page_no > 0x8FFFFFFFUL) { if (UNIV_UNLIKELY(*page_no > 0x8FFFFFFFUL)) {
recv_sys->found_corrupt_log = TRUE; recv_sys->found_corrupt_log = TRUE;
return(0); return(0);
} }
*body = new_ptr;
new_ptr = recv_parse_or_apply_log_rec_body(*type, new_ptr, end_ptr, new_ptr = recv_parse_or_apply_log_rec_body(*type, new_ptr, end_ptr,
NULL, NULL); NULL, NULL);
if (new_ptr == NULL) { if (UNIV_UNLIKELY(new_ptr == NULL)) {
return(0); return(0);
} }
......
...@@ -23,9 +23,9 @@ Catenates n bytes to the mtr log. */ ...@@ -23,9 +23,9 @@ Catenates n bytes to the mtr log. */
void void
mlog_catenate_string( mlog_catenate_string(
/*=================*/ /*=================*/
mtr_t* mtr, /* in: mtr */ mtr_t* mtr, /* in: mtr */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len) /* in: string length */ ulint len) /* in: string length */
{ {
dyn_array_t* mlog; dyn_array_t* mlog;
...@@ -302,14 +302,15 @@ corresponding log record to the mini-transaction log. */ ...@@ -302,14 +302,15 @@ corresponding log record to the mini-transaction log. */
void void
mlog_write_string( mlog_write_string(
/*==============*/ /*==============*/
byte* ptr, /* in: pointer where to write */ byte* ptr, /* in: pointer where to write */
byte* str, /* in: string to write */ const byte* str, /* in: string to write */
ulint len, /* in: string length */ ulint len, /* in: string length */
mtr_t* mtr) /* in: mini-transaction handle */ mtr_t* mtr) /* in: mini-transaction handle */
{ {
byte* log_ptr; byte* log_ptr;
if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { if (UNIV_UNLIKELY(ptr < buf_pool->frame_zero)
|| UNIV_UNLIKELY(ptr >= buf_pool->high_end)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to write to a stray memory location %p\n", ptr); "InnoDB: Error: trying to write to a stray memory location %p\n", ptr);
ut_error; ut_error;
......
...@@ -630,6 +630,8 @@ row_sel_get_clust_rec( ...@@ -630,6 +630,8 @@ row_sel_get_clust_rec(
ulint* offsets = offsets_; ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
*out_rec = NULL;
offsets = rec_get_offsets(rec, offsets = rec_get_offsets(rec,
btr_pcur_get_btr_cur(&plan->pcur)->index, btr_pcur_get_btr_cur(&plan->pcur)->index,
offsets, ULINT_UNDEFINED, &heap); offsets, ULINT_UNDEFINED, &heap);
...@@ -663,8 +665,6 @@ row_sel_get_clust_rec( ...@@ -663,8 +665,6 @@ row_sel_get_clust_rec(
clustered index record did not exist in the read view of clustered index record did not exist in the read view of
trx. */ trx. */
clust_rec = NULL;
goto func_exit; goto func_exit;
} }
...@@ -733,7 +733,6 @@ row_sel_get_clust_rec( ...@@ -733,7 +733,6 @@ row_sel_get_clust_rec(
if ((old_vers || rec_get_deleted_flag(rec, plan->table->comp)) if ((old_vers || rec_get_deleted_flag(rec, plan->table->comp))
&& !row_sel_sec_rec_is_for_clust_rec(rec, plan->index, && !row_sel_sec_rec_is_for_clust_rec(rec, plan->index,
clust_rec, index)) { clust_rec, index)) {
clust_rec = NULL;
goto func_exit; goto func_exit;
} }
} }
...@@ -742,8 +741,8 @@ row_sel_get_clust_rec( ...@@ -742,8 +741,8 @@ row_sel_get_clust_rec(
row_sel_fetch_columns(index, clust_rec, offsets, row_sel_fetch_columns(index, clust_rec, offsets,
UT_LIST_GET_FIRST(plan->columns)); UT_LIST_GET_FIRST(plan->columns));
func_exit:
*out_rec = clust_rec; *out_rec = clust_rec;
func_exit:
err = DB_SUCCESS; err = DB_SUCCESS;
err_exit: err_exit:
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
......
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