From 3cb7bf8170fb68dc6a0c967e7dbc8e7dba685e4a Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Mon, 22 Apr 2013 10:41:41 -0700 Subject: [PATCH] Initialize parameters in the constructor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- util/env_posix.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index 957c5b105..a12709a2d 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -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