]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/rados/rados.cc: restore ostream format
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 4 May 2015 23:44:05 +0000 (01:44 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 1 Jun 2015 04:59:26 +0000 (06:59 +0200)
CID 717133 (#1 of 1): Not restoring ostream format (STREAM_FORMAT_STATE)
95.  format_changed: fill changes the format state of std::cout for
     category fill.
100. end_of_path: Changing format state of stream std::cout for
     category fill without later restoring it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/tools/rados/rados.cc

index f9e4ee6637f4ac82b9a4ea49adc5bbe84fe3940f..8cc55eddc7d8716047a2b7f5dc43e91af45f53e8 100644 (file)
@@ -2206,6 +2206,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       localtime_r(&t, &bdt);
       cout << *i << "\t" << s << "\t";
 
+      std::ios_base::fmtflags original_flags = cout.flags();
       cout.setf(std::ios::right);
       cout.fill('0');
       cout << std::setw(4) << (bdt.tm_year+1900)
@@ -2216,7 +2217,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
           << ':' << std::setw(2) << bdt.tm_min
           << ':' << std::setw(2) << bdt.tm_sec
           << std::endl;
-      cout.unsetf(std::ios::right);
+      cout.flags(original_flags);
     }
     cout << snaps.size() << " snaps" << std::endl;
   }