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