From 9f0dbb4265fda241961f9dbef85765c11830f32e Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 23 Jun 2017 10:42:02 -0700 Subject: [PATCH] Squelch spurious warning on gcc --- CHANGELOG.md | 1 + include/beast/zlib/detail/deflate_stream.hpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e3351f5..763f596f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Version 66: * Add header aliases * basic_fields optimizations * Add http-server example +* Squelch spurious warning on gcc -------------------------------------------------------------------------------- diff --git a/include/beast/zlib/detail/deflate_stream.hpp b/include/beast/zlib/detail/deflate_stream.hpp index aa152bc2..a53fcaf5 100644 --- a/include/beast/zlib/detail/deflate_stream.hpp +++ b/include/beast/zlib/detail/deflate_stream.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -667,7 +668,7 @@ protected: template std::size_t doUpperBound (std::size_t sourceLen) const; template void doTune (int good_length, int max_lazy, int nice_length, int max_chain); template void doParams (z_params& zs, int level, Strategy strategy, error_code& ec); - template void doWrite (z_params& zs, Flush flush, error_code& ec); + template void doWrite (z_params& zs, boost::optional flush, error_code& ec); template void doDictionary (Byte const* dict, uInt dictLength, error_code& ec); template void doPrime (int bits, int value, error_code& ec); template void doPending (unsigned* value, int* bits); @@ -1014,10 +1015,14 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec) strategy_ = strategy; } +// VFALCO boost::optional param is a workaround for +// gcc "maybe uninitialized" warning +// https://github.com/vinniefalco/Beast/issues/532 +// template void deflate_stream:: -doWrite(z_params& zs, Flush flush, error_code& ec) +doWrite(z_params& zs, boost::optional flush, error_code& ec) { maybe_init(); @@ -1081,14 +1086,14 @@ doWrite(z_params& zs, Flush flush, error_code& ec) switch(strategy_) { case Strategy::huffman: - bstate = deflate_huff(zs, flush); + bstate = deflate_huff(zs, flush.get()); break; case Strategy::rle: - bstate = deflate_rle(zs, flush); + bstate = deflate_rle(zs, flush.get()); break; default: { - bstate = (this->*(get_config(level_).func))(zs, flush); + bstate = (this->*(get_config(level_).func))(zs, flush.get()); break; } }