Revision b45fbc1175fb83080405af6732881db272e462e0 authored by Prashant D on 28 November 2017, 21:15:20 UTC, committed by Facebook Github Bot on 28 November 2017, 21:27:08 UTC
Summary: ``` utilities/persistent_cache/block_cache_tier_file.cc 64struct CacheRecordHeader { 2. uninit_member: Non-static class member magic_ is not initialized in this constructor nor in any functions that it calls. 4. uninit_member: Non-static class member crc_ is not initialized in this constructor nor in any functions that it calls. 6. uninit_member: Non-static class member key_size_ is not initialized in this constructor nor in any functions that it calls. CID 1396161 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR) 8. uninit_member: Non-static class member val_size_ is not initialized in this constructor nor in any functions that it calls. 65 CacheRecordHeader() {} 66 CacheRecordHeader(const uint32_t magic, const uint32_t key_size, 67 const uint32_t val_size) 68 : magic_(magic), crc_(0), key_size_(key_size), val_size_(val_size) {} 69 1. member_decl: Class member declaration for magic_. 70 uint32_t magic_; 3. member_decl: Class member declaration for crc_. 71 uint32_t crc_; 5. member_decl: Class member declaration for key_size_. 72 uint32_t key_size_; 7. member_decl: Class member declaration for val_size_. 73 uint32_t val_size_; 74}; utilities/simulator_cache/sim_cache.cc: 157 miss_times_(0), CID 1396124 (#1 of 1): Uninitialized pointer field (UNINIT_CTOR) 2. uninit_member: Non-static class member stats_ is not initialized in this constructor nor in any functions that it calls. 158 hit_times_(0) {} 159 ``` Closes https://github.com/facebook/rocksdb/pull/3155 Differential Revision: D6427237 Pulled By: sagar0 fbshipit-source-id: 97e493da5fc043c5b9a3e0d33103442cffb75aad
1 parent 7b57510
log_buffer.cc
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include "util/log_buffer.h"
#include "port/sys_time.h"
#include "port/port.h"
namespace rocksdb {
LogBuffer::LogBuffer(const InfoLogLevel log_level,
Logger*info_log)
: log_level_(log_level), info_log_(info_log) {}
void LogBuffer::AddLogToBuffer(size_t max_log_size, const char* format,
va_list ap) {
if (!info_log_ || log_level_ < info_log_->GetInfoLogLevel()) {
// Skip the level because of its level.
return;
}
char* alloc_mem = arena_.AllocateAligned(max_log_size);
BufferedLog* buffered_log = new (alloc_mem) BufferedLog();
char* p = buffered_log->message;
char* limit = alloc_mem + max_log_size - 1;
// store the time
gettimeofday(&(buffered_log->now_tv), nullptr);
// Print the message
if (p < limit) {
va_list backup_ap;
va_copy(backup_ap, ap);
auto n = vsnprintf(p, limit - p, format, backup_ap);
#ifndef OS_WIN
// MS reports -1 when the buffer is too short
assert(n >= 0);
#endif
if (n > 0) {
p += n;
} else {
p = limit;
}
va_end(backup_ap);
}
if (p > limit) {
p = limit;
}
// Add '\0' to the end
*p = '\0';
logs_.push_back(buffered_log);
}
void LogBuffer::FlushBufferToLog() {
for (BufferedLog* log : logs_) {
const time_t seconds = log->now_tv.tv_sec;
struct tm t;
if (localtime_r(&seconds, &t) != nullptr) {
Log(log_level_, info_log_,
"(Original Log Time %04d/%02d/%02d-%02d:%02d:%02d.%06d) %s",
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
t.tm_sec, static_cast<int>(log->now_tv.tv_usec), log->message);
}
}
logs_.clear();
}
void LogToBuffer(LogBuffer* log_buffer, size_t max_log_size, const char* format,
...) {
if (log_buffer != nullptr) {
va_list ap;
va_start(ap, format);
log_buffer->AddLogToBuffer(max_log_size, format, ap);
va_end(ap);
}
}
void LogToBuffer(LogBuffer* log_buffer, const char* format, ...) {
const size_t kDefaultMaxLogSize = 512;
if (log_buffer != nullptr) {
va_list ap;
va_start(ap, format);
log_buffer->AddLogToBuffer(kDefaultMaxLogSize, format, ap);
va_end(ap);
}
}
} // namespace rocksdb
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...