Initialize parameters in the constructor.

Summary:
RocksDB doesn't build on Ubuntu VM .. shoudl be fixed with this patch.

g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

util/env_posix.cc:68:24: sorry, unimplemented: non-static data member initializers
util/env_posix.cc:68:24: error: ISO C++ forbids in-class initialization of non-const static member ‘use_os_buffer’
util/env_posix.cc:113:24: sorry, unimplemented: non-static data member initializers
util/env_posix.cc:113:24: error: ISO C++ forbids in-class initialization of non-const static member ‘use_os_buffer

Test Plan: make check

Reviewers: sheki, leveldb

Reviewed By: sheki

Differential Revision: https://reviews.facebook.net/D10461
This commit is contained in:
Dhruba Borthakur 2013-04-22 10:41:41 -07:00
parent b4243e5a3d
commit 3cb7bf8170

View File

@ -65,15 +65,14 @@ class PosixSequentialFile: public SequentialFile {
std::string filename_;
FILE* file_;
int fd_;
bool use_os_buffer = true;
bool use_os_buffer_;
public:
PosixSequentialFile(const std::string& fname, FILE* f,
const EnvOptions& options)
: filename_(fname), file_(f) {
fd_ = fileno(f);
: filename_(fname), file_(f), fd_(fileno(f)),
use_os_buffer_(options.UseOsBuffer()) {
assert(!options.UseMmapReads());
use_os_buffer = options.UseOsBuffer();
}
virtual ~PosixSequentialFile() { fclose(file_); }
@ -89,7 +88,7 @@ class PosixSequentialFile: public SequentialFile {
s = IOError(filename_, errno);
}
}
if (!use_os_buffer) {
if (!use_os_buffer_) {
// we need to fadvise away the entire range of pages because
// we do not want readahead pages to be cached.
posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages
@ -110,17 +109,16 @@ class PosixRandomAccessFile: public RandomAccessFile {
private:
std::string filename_;
int fd_;
bool use_os_buffer = true;
bool use_os_buffer_;
public:
PosixRandomAccessFile(const std::string& fname, int fd,
const EnvOptions& options)
: filename_(fname), fd_(fd) {
: filename_(fname), fd_(fd), use_os_buffer_(options.UseOsBuffer()) {
assert(!options.UseMmapReads());
if (!options.UseReadahead()) { // disable read-aheads
posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
}
use_os_buffer = options.UseOsBuffer();
}
virtual ~PosixRandomAccessFile() { close(fd_); }
@ -133,7 +131,7 @@ class PosixRandomAccessFile: public RandomAccessFile {
// An error: return a non-ok status
s = IOError(filename_, errno);
}
if (!use_os_buffer) {
if (!use_os_buffer_) {
// we need to fadvise away the entire range of pages because
// we do not want readahead pages to be cached.
posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages