From: Patrick Donnelly Date: Wed, 2 Jan 2019 18:07:45 +0000 (-0800) Subject: common: restore constructor fmtflags on clear X-Git-Tag: v14.1.0~369^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F25751%2Fhead;p=ceph.git common: restore constructor fmtflags on clear This is to prevent fmtflags changes from a previous use (e.g. debug message) leaking into the the next (i.e. the next debug message). Signed-off-by: Patrick Donnelly --- diff --git a/src/common/StackStringStream.h b/src/common/StackStringStream.h index 522abc0749a..352b545d4bc 100644 --- a/src/common/StackStringStream.h +++ b/src/common/StackStringStream.h @@ -92,7 +92,7 @@ template class StackStringStream : public std::basic_ostream { public: - StackStringStream() : basic_ostream(&ssb) {} + StackStringStream() : basic_ostream(&ssb), default_fmtflags(flags()) {} StackStringStream(const StackStringStream& o) = delete; StackStringStream& operator=(const StackStringStream& o) = delete; StackStringStream(StackStringStream&& o) = delete; @@ -101,6 +101,7 @@ public: void reset() { clear(); /* reset state flags */ + flags(default_fmtflags); /* reset fmtflags to constructor defaults */ ssb.clear(); } @@ -110,6 +111,7 @@ public: private: StackStringBuf ssb; + fmtflags const default_fmtflags; }; /* In an ideal world, we could use StackStringStream indiscriminately, but alas