[rtems-tools PATCH 2/2] rtemstoolkit, linkers: Fix C++17 warnings

chrisj at rtems.org chrisj at rtems.org
Wed Nov 22 03:36:20 UTC 2023


From: Chris Johns <chrisj at rtems.org>

Closes #4970
---
 linkers/rtems-exeinfo.cpp |  3 +--
 rtemstoolkit/rld-elf.cpp  | 12 ------------
 rtemstoolkit/rld-elf.h    |  5 -----
 rtemstoolkit/rld-rap.cpp  |  9 ++-------
 rtemstoolkit/rld.cpp      | 14 ++++++++------
 5 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp
index 0900812..0b43403 100644
--- a/linkers/rtems-exeinfo.cpp
+++ b/linkers/rtems-exeinfo.cpp
@@ -223,8 +223,7 @@ namespace rld
      * Helper for for_each to filter and load the sections we wish to
      * dump.
      */
-    class section_loader:
-      public std::unary_function < const files::section, void >
+    class section_loader
     {
     public:
 
diff --git a/rtemstoolkit/rld-elf.cpp b/rtemstoolkit/rld-elf.cpp
index 68efdbe..8b55818 100644
--- a/rtemstoolkit/rld-elf.cpp
+++ b/rtemstoolkit/rld-elf.cpp
@@ -200,18 +200,6 @@ namespace rld
                   << std::endl;
     }
 
-    section::section (const section& orig)
-      : file_ (orig.file_),
-        index_ (orig.index_),
-        name_ (orig.name_),
-        scn (orig.scn),
-        shdr (orig.shdr),
-        data_ (orig.data_),
-        rela (orig.rela),
-        relocs (orig.relocs)
-    {
-    }
-
     section::section ()
       : file_ (0),
         index_ (-1),
diff --git a/rtemstoolkit/rld-elf.h b/rtemstoolkit/rld-elf.h
index 4919135..d66eee5 100644
--- a/rtemstoolkit/rld-elf.h
+++ b/rtemstoolkit/rld-elf.h
@@ -174,11 +174,6 @@ namespace rld
        */
       section (file& file_, int index);
 
-      /**
-       * Copy constructor.
-       */
-      section (const section& orig);
-
       /**
        * Default constructor.
        */
diff --git a/rtemstoolkit/rld-rap.cpp b/rtemstoolkit/rld-rap.cpp
index 93ffbdc..045536a 100644
--- a/rtemstoolkit/rld-rap.cpp
+++ b/rtemstoolkit/rld-rap.cpp
@@ -696,8 +696,7 @@ namespace rld
      * Helper for for_each to merge the related object sections into the RAP
      * section.
      */
-    class section_merge:
-      public std::unary_function < const files::section, void >
+    class section_merge
     {
     public:
 
@@ -1191,8 +1190,7 @@ namespace rld
     /**
      * Helper for for_each to write out the various sections.
      */
-    class section_writer:
-      public std::unary_function < object, void >
+    class section_writer
     {
     public:
 
@@ -1364,8 +1362,6 @@ namespace rld
     void
     image::write_relocations (compress::compressor& comp)
     {
-      uint32_t rr = 0;
-
       for (int s = 0; s < rap_secs; ++s)
       {
         uint32_t count = get_relocations (s);
@@ -1515,7 +1511,6 @@ namespace rld
 
             ++rc;
             ++sr;
-            ++rr;
           }
         }
       }
diff --git a/rtemstoolkit/rld.cpp b/rtemstoolkit/rld.cpp
index 90fb39d..d0848ad 100644
--- a/rtemstoolkit/rld.cpp
+++ b/rtemstoolkit/rld.cpp
@@ -106,9 +106,10 @@ namespace rld
   ltrim (const std::string& s)
   {
     std::string t = s;
-    t.erase (t.begin (),
-             std::find_if (t.begin (), t.end (),
-                         std::not1 (std::ptr_fun < int, int > (std::isspace))));
+    auto non_space =
+      std::find_if (t.begin (), t.end (),
+                    [](unsigned char c) { return !std::isspace (c); });
+    t.erase (t.begin (), non_space);
     return t;
   }
 
@@ -116,9 +117,10 @@ namespace rld
   rtrim (const std::string& s)
   {
     std::string t = s;
-    t.erase (std::find_if (t.rbegin (), t.rend (),
-                           std::not1 (std::ptr_fun < int, int > (std::isspace))).base(),
-             t.end());
+    auto last_space =
+      std::find_if (t.rbegin (), t.rend (),
+                    [](unsigned char c) { return !std::isspace (c); }).base();
+    t.erase (last_space, t.end());
     return t;
   }
 
-- 
2.37.1



More information about the devel mailing list