summaryrefslogtreecommitdiff
path: root/storage/innobase/sync
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-03-01 08:27:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-03-07 19:07:27 +0200
commit89d80c1b0be94639d0913dee7b6a284c32787b09 (patch)
treea08340d45a09b067df4490259f68b5a3f9d2fa03 /storage/innobase/sync
parentd2f5e624223fe502ddf4c6f42062c29edb988627 (diff)
downloadmariadb-git-89d80c1b0be94639d0913dee7b6a284c32787b09.tar.gz
Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with ulonglong. Change some parameters to this type. Use size_t in a few more places. Declare many flag constants as unsigned to avoid sign mismatch when shifting bits or applying the unary ~ operator. When applying the unary ~ operator to enum constants, explictly cast the result to an unsigned type, because enum constants can be treated as signed. In InnoDB, change the source code line number parameters from ulint to unsigned type. Also, make some InnoDB functions return a narrower type (unsigned or uint32_t instead of ulint; bool instead of ibool).
Diffstat (limited to 'storage/innobase/sync')
-rw-r--r--storage/innobase/sync/sync0arr.cc51
-rw-r--r--storage/innobase/sync/sync0rw.cc23
2 files changed, 37 insertions, 37 deletions
diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc
index c9423a04fba..1b561dc3297 100644
--- a/storage/innobase/sync/sync0arr.cc
+++ b/storage/innobase/sync/sync0arr.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -117,7 +117,7 @@ struct sync_cell_t {
const char* file; /*!< in debug version file where
requested */
ulint line; /*!< in debug version line where
- requested */
+ requested, or ULINT_UNDEFINED */
os_thread_id_t thread_id; /*!< thread id of this waiting
thread */
bool waiting; /*!< TRUE if the thread has already
@@ -213,24 +213,16 @@ sync_array_t::sync_array_t(ulint num_cells)
UNIV_NOTHROW
:
n_reserved(),
- n_cells(),
- array(),
+ n_cells(num_cells),
+ array(UT_NEW_ARRAY_NOKEY(sync_cell_t, num_cells)),
mutex(),
res_count(),
next_free_slot(),
- first_free_slot()
+ first_free_slot(ULINT_UNDEFINED)
{
ut_a(num_cells > 0);
- array = UT_NEW_ARRAY_NOKEY(sync_cell_t, num_cells);
-
- ulint sz = sizeof(sync_cell_t) * num_cells;
-
- memset(array, 0x0, sz);
-
- n_cells = num_cells;
-
- first_free_slot = ULINT_UNDEFINED;
+ memset(array, 0x0, sizeof(sync_cell_t) * n_cells);
/* Then create the mutex to protect the wait array */
mutex_create(LATCH_ID_SYNC_ARRAY_MUTEX, &mutex);
@@ -344,7 +336,7 @@ sync_array_reserve_cell(
void* object, /*!< in: pointer to the object to wait for */
ulint type, /*!< in: lock request type */
const char* file, /*!< in: file where requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
sync_cell_t* cell;
@@ -604,15 +596,15 @@ sync_array_cell_print(
fprintf(file,
"number of readers %lu, waiters flag %lu,"
" lock_word: %lx\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
+ "Last time read locked in file %s line %u\n"
+ "Last time write locked in file %s line %u\n",
(ulint) rw_lock_get_reader_count(rwlock),
(ulint) rwlock->waiters,
rwlock->lock_word,
innobase_basename(rwlock->last_s_file_name),
- (ulint) rwlock->last_s_line,
+ rwlock->last_s_line,
rwlock->last_x_file_name,
- (ulint) rwlock->last_x_line);
+ rwlock->last_x_line);
/* JAN: TODO: FIX LATER
fprintf(file,
@@ -1339,7 +1331,8 @@ sync_arr_fill_sys_semphore_waits_table(
(longlong)os_thread_pf(cell->thread)));
*/
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_FILE], innobase_basename(cell->file)));
- OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LINE], cell->line));
+ OK(fields[SYS_SEMAPHORE_WAITS_LINE]->store(cell->line, true));
+ fields[SYS_SEMAPHORE_WAITS_LINE]->set_notnull();
OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAIT_TIME], (ulint)difftime(time(NULL), cell->reservation_time)));
if (type == SYNC_MUTEX) {
@@ -1352,13 +1345,16 @@ sync_arr_fill_sys_semphore_waits_table(
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_WAIT_TYPE], "MUTEX"));
//OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID], (longlong)mutex->thread_id));
//OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_HOLDER_FILE], innobase_basename(mutex->file_name)));
- //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE], mutex->line));
+ //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->store(mutex->line, true));
+ //fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->set_notnull();
//OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_CREATED_FILE], innobase_basename(mutex->cfile_name)));
- //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_CREATED_LINE], mutex->cline));
+ //OK(fields[SYS_SEMAPHORE_WAITS_CREATED_LINE]->store(mutex->cline, true));
+ //fields[SYS_SEMAPHORE_WAITS_CREATED_LINE]->set_notnull();
//OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG], (longlong)mutex->waiters));
//OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD], (longlong)mutex->lock_word));
//OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE], innobase_basename(mutex->file_name)));
- //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE], mutex->line));
+ //OK(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->store(mutex->line, true));
+ //fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->set_notnull();
//OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT], mutex->count_os_wait));
}
} else if (type == RW_LOCK_X_WAIT
@@ -1398,14 +1394,17 @@ sync_arr_fill_sys_semphore_waits_table(
//OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID], (longlong)rwlock->thread_id));
//OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_HOLDER_FILE], innobase_basename(rwlock->file_name)));
- //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE], rwlock->line));
+ //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->store(rwlock->line, true));
+ //fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->set_notnull();
OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_READERS], rw_lock_get_reader_count(rwlock)));
OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG], (longlong)rwlock->waiters));
OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD], (longlong)rwlock->lock_word));
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_LAST_READER_FILE], innobase_basename(rwlock->last_s_file_name)));
- OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LAST_READER_LINE], rwlock->last_s_line));
+ OK(fields[SYS_SEMAPHORE_WAITS_LAST_READER_LINE]->store(rwlock->last_s_line, true));
+ fields[SYS_SEMAPHORE_WAITS_LAST_READER_LINE]->set_notnull();
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE], innobase_basename(rwlock->last_x_file_name)));
- OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE], rwlock->last_x_line));
+ OK(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->store(rwlock->last_x_line, true));
+ fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->set_notnull();
OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT], rwlock->count_os_wait));
}
}
diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc
index 9160d9c8bee..497f7f3f9e9 100644
--- a/storage/innobase/sync/sync0rw.cc
+++ b/storage/innobase/sync/sync0rw.cc
@@ -2,6 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -203,7 +204,7 @@ rw_lock_create_func(
latch_level_t level, /*!< in: level */
#endif /* UNIV_DEBUG */
const char* cfile_name, /*!< in: file name where created */
- ulint cline) /*!< in: file line where created */
+ unsigned cline) /*!< in: file line where created */
{
#if defined(UNIV_DEBUG) && !defined(UNIV_PFS_RWLOCK)
/* It should have been created in pfs_rw_lock_create_func() */
@@ -236,7 +237,7 @@ rw_lock_create_func(
split the source file anyway. Or create the locks on lines
less than 8192. cline is unsigned:13. */
ut_ad(cline <= 8192);
- lock->cline = (unsigned int) cline;
+ lock->cline = cline;
lock->count_os_wait = 0;
lock->last_s_file_name = "not yet reserved";
lock->last_x_file_name = "not yet reserved";
@@ -295,7 +296,7 @@ rw_lock_s_lock_spin(
ulint pass, /*!< in: pass value; != 0, if the lock
will be passed to another thread to unlock */
const char* file_name, /*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
ulint i = 0; /* spin round count */
sync_array_t* sync_arr;
@@ -425,7 +426,7 @@ rw_lock_x_lock_wait_func(
#endif
lint threshold,/*!< in: threshold to wait for */
const char* file_name,/*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
ulint i = 0;
ulint n_spins = 0;
@@ -520,7 +521,7 @@ rw_lock_x_lock_low(
ulint pass, /*!< in: pass value; != 0, if the lock will
be passed to another thread to unlock */
const char* file_name,/*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
if (rw_lock_lock_word_decr(lock, X_LOCK_DECR, X_LOCK_HALF_DECR)) {
@@ -578,7 +579,7 @@ rw_lock_x_lock_low(
ut_d(rw_lock_add_debug_info(lock, pass, RW_LOCK_X, file_name, line));
lock->last_x_file_name = file_name;
- lock->last_x_line = (unsigned int) line;
+ lock->last_x_line = line;
return(TRUE);
}
@@ -593,7 +594,7 @@ rw_lock_sx_lock_low(
ulint pass, /*!< in: pass value; != 0, if the lock will
be passed to another thread to unlock */
const char* file_name,/*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
if (rw_lock_lock_word_decr(lock, X_LOCK_HALF_DECR, X_LOCK_HALF_DECR)) {
@@ -652,7 +653,7 @@ rw_lock_sx_lock_low(
ut_d(rw_lock_add_debug_info(lock, pass, RW_LOCK_SX, file_name, line));
lock->last_x_file_name = file_name;
- lock->last_x_line = (unsigned int) line;
+ lock->last_x_line = line;
return(TRUE);
}
@@ -673,7 +674,7 @@ rw_lock_x_lock_func(
ulint pass, /*!< in: pass value; != 0, if the lock will
be passed to another thread to unlock */
const char* file_name,/*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
ulint i = 0;
sync_array_t* sync_arr;
@@ -775,7 +776,7 @@ rw_lock_sx_lock_func(
ulint pass, /*!< in: pass value; != 0, if the lock will
be passed to another thread to unlock */
const char* file_name,/*!< in: file name where lock requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
ulint i = 0;
@@ -928,7 +929,7 @@ rw_lock_add_debug_info(
ulint pass, /*!< in: pass value */
ulint lock_type, /*!< in: lock type */
const char* file_name, /*!< in: file where requested */
- ulint line) /*!< in: line where requested */
+ unsigned line) /*!< in: line where requested */
{
ut_ad(file_name != NULL);