From ea660b57d65d68d521287c903459b6dd3b2804d0 Mon Sep 17 00:00:00 2001 From: costan Date: Fri, 17 Aug 2018 12:02:02 -0700 Subject: [PATCH] Fix unused private field warning in NDEBUG builds. --- snappy.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/snappy.cc b/snappy.cc index 19fc963..e594bb9 100644 --- a/snappy.cc +++ b/snappy.cc @@ -1048,12 +1048,14 @@ size_t Compress(Source* reader, Sink* writer) { // Writer template argument to SnappyDecompressor::DecompressAllTags(). class SnappyIOVecWriter { private: - const struct iovec* output_iov_; - // output_iov_end_ is set to iov + count and used to determine when // the end of the iovs is reached. const struct iovec* output_iov_end_; +#if !defined(NDEBUG) + const struct iovec* output_iov_; +#endif // !defined(NDEBUG) + // Current iov that is being written into. const struct iovec* curr_iov_; @@ -1077,8 +1079,10 @@ class SnappyIOVecWriter { // Does not take ownership of iov. iov must be valid during the // entire lifetime of the SnappyIOVecWriter. inline SnappyIOVecWriter(const struct iovec* iov, size_t iov_count) - : output_iov_(iov), - output_iov_end_(iov + iov_count), + : output_iov_end_(iov + iov_count), +#if !defined(NDEBUG) + output_iov_(iov), +#endif // !defined(NDEBUG) curr_iov_(iov), curr_iov_output_(iov_count ? reinterpret_cast(iov->iov_base) : nullptr), @@ -1163,7 +1167,9 @@ class SnappyIOVecWriter { offset -= from_iov_offset; --from_iov; +#if !defined(NDEBUG) assert(from_iov >= output_iov_); +#endif // !defined(NDEBUG) from_iov_offset = from_iov->iov_len; }