[PATCH v1 2/5] rtems-exeinfo.cpp: Reset cout stream flags

Ryan Long ryan.long at oarcorp.com
Wed Aug 4 15:54:21 UTC 2021


CID 1503006: Not restoring ostream format
CID 1503007: Not restoring ostream format

Remove ostream_guard, add restiosflags() call, and store the value of precision
before it is changed restore it afterwards.

Closes #4469
---
 linkers/rtems-exeinfo.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp
index c9bf5b6..fe484ea 100644
--- a/linkers/rtems-exeinfo.cpp
+++ b/linkers/rtems-exeinfo.cpp
@@ -47,14 +47,11 @@
 #include <rld-files.h>
 #include <rld-process.h>
 #include <rld-rtems.h>
-#include <rtems-utils.h>
 
 #ifndef HAVE_KILL
 #define kill(p,s) raise(s)
 #endif
 
-typedef rtems::utils::ostream_guard ostream_guard;
-
 namespace rld
 {
   namespace exeinfo
@@ -369,7 +366,6 @@ namespace rld
        */
 
       rld::strings all_flags;
-      ostream_guard old_state( std::cout );
 
       size_t source_max = 0;
 
@@ -481,7 +477,8 @@ namespace rld
           {
             std::cout << "   | "
                       << std::setw (source_max + 1) << std::left
-                      << rld::path::basename (s.source);
+                      << rld::path::basename (s.source)
+                      << std::resetiosflags( std::ios_base::left );
             if (!s.flags.empty ())
             {
               bool first = true;
@@ -636,7 +633,6 @@ namespace rld
 
     void image::output_tls ()
     {
-      ostream_guard old_state( std::cout );
 
       symbols::symbol* tls_data_begin = symbols.find_global("_TLS_Data_begin");
       symbols::symbol* tls_data_end = symbols.find_global("_TLS_Data_end");
@@ -714,7 +710,8 @@ namespace rld
                 << "    data addr : 0x" << std::setw (8) << tls_data_begin->value ()
                 << std::endl
                 << std::dec << std::setfill (' ')
-                << std::endl;
+                << std::endl
+                << std::resetiosflags( std::ios_base::right );
     }
 
     void image::config(const std::string name)
-- 
1.8.3.1



More information about the devel mailing list