I have one concern with this patch. See below:
On Thu, 30 Apr 2015 at 11:45 Jan Lindström <
jan.lindstrom@mariadb.com> wrote:
revision-id: 13ecde851f08a7952f774707b19734f351bb6598
parent(s): 5027e0b035f96e2583eff2d1ac71c7c44a093ac8
committer: Jan Lindström
branch nick: 10.0-git
timestamp: 2015-04-30 11:44:34 +0300
message:
Fix compiler warnings.
---
storage/innobase/sync/sync0sync.cc | 27 +++++++++++++--------------
storage/xtradb/sync/sync0sync.cc | 27 +++++++++++++--------------
2 files changed, 26 insertions(+), 28 deletions(-)
diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc
index 121f8e9..78d86f3 100644
--- a/storage/innobase/sync/sync0sync.cc
+++ b/storage/innobase/sync/sync0sync.cc
@@ -862,10 +862,10 @@ sync_thread_levels_g(
{
ulint i;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
const sync_level_t* slot;
I think this here has to be arr->at(i), or &(*arr)[i]. Doing &arr[i] will actually get the i'th std::vector<> which does not exist, since arr is a pointer to only one std::vector<>.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level <= limit) {
if (warn) {
@@ -897,10 +897,10 @@ sync_thread_levels_contain(
{
ulint i;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level == level) {
@@ -944,10 +944,10 @@ sync_thread_levels_contains(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level == level) {
@@ -993,10 +993,10 @@ sync_thread_levels_nonempty_gen(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; ++i) {
+ for (i = 0; i < arr->size(); ++i) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL
&& (!dict_mutex_allowed
@@ -1053,10 +1053,10 @@ sync_thread_levels_nonempty_trx(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; ++i) {
+ for (i = 0; i < arr->size(); ++i) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL
&& (!has_search_latch
@@ -1331,7 +1331,7 @@ sync_thread_add_level(
sync_level.latch = latch;
sync_level.level = level;
- array->elems.push_back(sync_level);
+ array->push_back(sync_level);
mutex_exit(&sync_thread_mutex);
}
@@ -1377,14 +1377,14 @@ sync_thread_reset_level(
array = thread_slot->levels;
- for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it != array->elems.end(); ++it) {
+ for (std::vector<sync_level_t>::iterator it = array->begin(); it != array->end(); ++it) {
sync_level_t level = *it;
if (level.latch != latch) {
continue;
}
- array->elems.erase(it);
+ array->erase(it);
mutex_exit(&sync_thread_mutex);
return(TRUE);
}
@@ -1471,7 +1471,6 @@ sync_thread_level_arrays_free(void)
/* If this slot was allocated then free the slot memory too. */
if (slot->levels != NULL) {
- slot->levels->elems.erase(slot->levels->elems.begin(),slot->levels->elems.end());
delete slot->levels;
}
}
diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc
index d0e3b71..9dcdd9c 100644
--- a/storage/xtradb/sync/sync0sync.cc
+++ b/storage/xtradb/sync/sync0sync.cc
@@ -970,10 +970,10 @@ sync_thread_levels_g(
{
ulint i;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level <= limit) {
if (warn) {
@@ -1005,10 +1005,10 @@ sync_thread_levels_contain(
{
ulint i;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level == level) {
@@ -1052,10 +1052,10 @@ sync_thread_levels_contains(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; i++) {
+ for (i = 0; i < arr->size(); i++) {
sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (sync_level_t*)&arr[i];
if (slot->latch != NULL && slot->level == level) {
@@ -1101,10 +1101,10 @@ sync_thread_levels_nonempty_gen(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; ++i) {
+ for (i = 0; i < arr->size(); ++i) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL
&& (!dict_mutex_allowed
@@ -1161,10 +1161,10 @@ sync_thread_levels_nonempty_trx(
arr = thread_slot->levels;
- for (i = 0; i < arr->n_elems; ++i) {
+ for (i = 0; i < arr->size(); ++i) {
const sync_level_t* slot;
Same here.
- slot = &arr->elems[i];
+ slot = (const sync_level_t*)&arr[i];
if (slot->latch != NULL
&& (!has_search_latch
@@ -1456,7 +1456,7 @@ sync_thread_add_level(
sync_level.latch = latch;
sync_level.level = level;
- array->elems.push_back(sync_level);
+ array->push_back(sync_level);
mutex_exit(&sync_thread_mutex);
}
@@ -1502,14 +1502,14 @@ sync_thread_reset_level(
array = thread_slot->levels;
- for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it != array->elems.end(); ++it) {
+ for (std::vector<sync_level_t>::iterator it = array->begin(); it != array->end(); ++it) {
sync_level_t level = *it;
if (level.latch != latch) {
continue;
}
- array->elems.erase(it);
+ array->erase(it);
mutex_exit(&sync_thread_mutex);
return(TRUE);
}
@@ -1597,7 +1597,6 @@ sync_thread_level_arrays_free(void)
/* If this slot was allocated then free the slot memory too. */
if (slot->levels != NULL) {
- slot->levels->elems.erase(slot->levels->elems.begin(),slot->levels->elems.end());
delete slot->levels;
}
}