]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: restore constructor fmtflags on clear 25751/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 2 Jan 2019 18:07:45 +0000 (10:07 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 15 Jan 2019 14:41:39 +0000 (06:41 -0800)
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 <pdonnell@redhat.com>
src/common/StackStringStream.h

index 522abc0749a944a1d106afab5b1fafd76d5dcfba..352b545d4bcc922979335eeafcdd77e2f8a6cea8 100644 (file)
@@ -92,7 +92,7 @@ template<std::size_t SIZE>
 class StackStringStream : public std::basic_ostream<char>
 {
 public:
-  StackStringStream() : basic_ostream<char>(&ssb) {}
+  StackStringStream() : basic_ostream<char>(&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<SIZE> ssb;
+  fmtflags const default_fmtflags;
 };
 
 /* In an ideal world, we could use StackStringStream indiscriminately, but alas