提交 72505bdd 编写于 作者: L Longda Feng

fix compile warning

上级 314db4db
......@@ -213,16 +213,15 @@ int Log::rotate_by_day(const int year, const int month, const int day)
return 0;
}
#define MAX_LOG_NUM 999
int Log::rename_old_logs()
{
int log_index = 1;
int max_log_index = 0;
char log_index_str[4] = {0};
while (log_index < 999) {
snprintf(log_index_str, sizeof(log_index_str), "%03d", log_index);
std::string log_name = log_name_ + "." + log_index_str;
while (log_index < MAX_LOG_NUM) {
std::string log_name = log_name_ + "." + size_to_pad_str(log_index, 3);
int result = access(log_name.c_str(), R_OK);
if (result) {
break;
......@@ -232,15 +231,16 @@ int Log::rename_old_logs()
log_index++;
}
if (log_index == MAX_LOG_NUM) {
std::string log_name_rm = log_name_ + "." + size_to_pad_str(log_index, 3);
remove(log_name_rm.c_str());
}
log_index = max_log_index;
while (log_index > 0) {
snprintf(log_index_str, sizeof(log_index_str), "%03d", log_index);
std::string log_name_old = log_name_ + "." + size_to_pad_str(log_index, 3);
std::string log_name_old = log_name_ + "." + log_index_str;
snprintf(log_index_str, sizeof(log_index_str), "%03d", log_index + 1);
std::string log_name_new = log_name_ + "." + log_index_str;
std::string log_name_new = log_name_ + "." + size_to_pad_str(log_index + 1, 3);
int result = rename(log_name_old.c_str(), log_name_new.c_str());
if (result) {
......
......@@ -63,7 +63,14 @@ int daemonize_service(bool close_std_streams)
{
int nochdir = 1;
int noclose = close_std_streams ? 0 : 1;
#ifdef __MACH__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
int rc = daemon(nochdir, noclose);
#ifdef __MACH__
#pragma GCC diagnostic pop
#endif
// Here after the fork; the parent is dead and setsid() is called
if (rc != 0) {
std::cerr << "Error: unable to daemonize: " << strerror(errno) << "\n";
......
......@@ -458,13 +458,20 @@ void TimerStage::check_timer()
// It is ok to hold the mutex while executing this loop.
// Triggering the events only enqueues the event on the
// caller's queue--it does not perform any real work.
#ifdef __MACH__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpotentially-evaluated-expression"
#endif
for (std::list<StageEvent *>::iterator i = done_events.begin(); i != done_events.end(); ++i) {
LOG_TRACE(
"triggering timer event: sec=%ld, usec=%ld, typeid=%s\n", now.tv_sec, now.tv_usec, typeid(**i).name());
"triggering timer event: sec=%ld, usec=%ld, typeid=%s\n", now.tv_sec, now.tv_usec, typeid(*(*i)).name());
(*i)->done();
--num_events_;
}
}
#ifdef __MACH__
#pragma GCC diagnostic pop
#endif
done_events.clear();
// Check if the 'shutdown' signal has been received. The
......
......@@ -119,9 +119,9 @@ RC CLogRecord::copy_record(void *dest, int start_off, int copy_len)
} else if (flag_ != REDO_INSERT) {
memcpy(dest, (char *)log_rec + start_off, copy_len);
} else {
if (start_off > CLOG_INS_REC_NODATA_SIZE) {
if (start_off > (int)CLOG_INS_REC_NODATA_SIZE) {
memcpy(dest, log_rec->ins.data_ + start_off - CLOG_INS_REC_NODATA_SIZE, copy_len);
} else if (start_off + copy_len <= CLOG_INS_REC_NODATA_SIZE) {
} else if (start_off + copy_len <= (int)CLOG_INS_REC_NODATA_SIZE) {
memcpy(dest, (char *)log_rec + start_off, copy_len);
} else {
memcpy(dest, (char *)log_rec + start_off, CLOG_INS_REC_NODATA_SIZE - start_off);
......@@ -194,7 +194,7 @@ RC CLogBuffer::append_log_record(CLogRecord *log_rec, int &start_off)
write_offset_ += CLOG_BLOCK_HDR_SIZE;
return append_log_record(log_rec, start_off);
} else {
if (logrec_left_len <= (CLOG_BLOCK_DATA_SIZE - log_block->log_block_hdr_.log_data_len_)) { // 不需要再跨block存放
if (logrec_left_len <= ((int32_t)CLOG_BLOCK_DATA_SIZE - log_block->log_block_hdr_.log_data_len_)) { // 不需要再跨block存放
if (log_block->log_block_hdr_.log_data_len_ == 0) { // 当前为新block
if (start_off == 0) {
log_block->log_block_hdr_.first_rec_offset_ = CLOG_BLOCK_HDR_SIZE;
......@@ -315,7 +315,7 @@ RC CLogFile::recover(CLogMTRManager *mtr_mgr, CLogBuffer *log_buffer)
log_buffer->set_current_block_no(log_block->log_block_hdr_.log_block_no);
int16_t rec_offset = CLOG_BLOCK_HDR_SIZE;
while (rec_offset < CLOG_BLOCK_HDR_SIZE + log_block->log_block_hdr_.log_data_len_) {
while (rec_offset < (int16_t)CLOG_BLOCK_HDR_SIZE + log_block->log_block_hdr_.log_data_len_) {
block_recover(log_block, rec_offset, &logrec_buf, log_rec);
if (log_rec != nullptr) {
CLogManager::gloabl_lsn_ = log_rec->get_lsn() + log_rec->get_logrec_len();
......@@ -324,7 +324,7 @@ RC CLogFile::recover(CLogMTRManager *mtr_mgr, CLogBuffer *log_buffer)
}
}
if (log_block->log_block_hdr_.log_data_len_ < CLOG_BLOCK_DATA_SIZE) { // 最后一个block
if (log_block->log_block_hdr_.log_data_len_ < (int16_t)CLOG_BLOCK_DATA_SIZE) { // 最后一个block
log_buffer->block_copy(0, log_block);
log_buffer->set_write_block_offset(0);
log_buffer->set_write_offset(log_block->log_block_hdr_.log_data_len_ + CLOG_BLOCK_HDR_SIZE);
......@@ -355,7 +355,7 @@ RC CLogFile::block_recover(CLogBlock *block, int16_t &offset, CLogRecordBuf *log
logrec_buf->write_offset_ += block->log_block_hdr_.first_rec_offset_ - CLOG_BLOCK_HDR_SIZE;
offset += block->log_block_hdr_.first_rec_offset_ - CLOG_BLOCK_HDR_SIZE;
} else {
if (CLOG_BLOCK_SIZE - offset < sizeof(CLogRecordHeader)) { // 一定是跨block的第一部分
if (CLOG_BLOCK_SIZE - offset < (int32_t)sizeof(CLogRecordHeader)) { // 一定是跨block的第一部分
// 此时无法确定log record的长度
// 开始写入logrec_buf
memcpy(&logrec_buf->buffer_[logrec_buf->write_offset_], (char *)block + (int)offset, CLOG_BLOCK_SIZE - offset);
......@@ -367,7 +367,7 @@ RC CLogFile::block_recover(CLogBlock *block, int16_t &offset, CLogRecordBuf *log
memset(logrec_buf, 0, sizeof(CLogRecordBuf));
} else {
CLogRecordHeader *logrec_hdr = (CLogRecordHeader *)((char *)block + (int)offset);
if (logrec_hdr->logrec_len_ <= CLOG_BLOCK_SIZE - offset) {
if (logrec_hdr->logrec_len_ <= (int32_t)CLOG_BLOCK_SIZE - offset) {
log_rec = new CLogRecord((char *)block + (int)offset);
offset += logrec_hdr->logrec_len_;
} else { // 此时为跨block的第一部分
......
......@@ -161,7 +161,7 @@ RC Db::recover()
{
RC rc = RC::SUCCESS;
if ((rc = clog_manager_->recover()) == RC::SUCCESS) {
uint32_t max_trx_id = 0;
int32_t max_trx_id = 0;
CLogMTRManager *mtr_manager = clog_manager_->get_mtr_manager();
for (auto it = mtr_manager->log_redo_list.begin(); it != mtr_manager->log_redo_list.end(); it++) {
CLogRecord *clog_record = *it;
......
......@@ -41,9 +41,7 @@ int k = 0;
void init_bpm()
{
if (&BufferPoolManager::instance() == nullptr) {
BufferPoolManager::set_instance(&bpm);
}
BufferPoolManager::set_instance(&bpm);
}
void test_insert()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册