New Defects reported by Coverity Scan for RTEMS-Tools

scan-admin at coverity.com scan-admin at coverity.com
Sun Dec 24 19:18:18 UTC 2023


Hi,

Please find the latest report on new defect(s) introduced to RTEMS-Tools found with Coverity Scan.

39 new defect(s) introduced to RTEMS-Tools found with Coverity Scan.
12 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 20 of 39 defect(s)


** CID 1574966:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_i386.cc: 17 in Target::Target_i386::Target_i386(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574966:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_i386.cc: 17 in Target::Target_i386::Target_i386(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
11     #include <string.h>
12     #include <unistd.h>
13     
14     namespace Target {
15     
16       Target_i386::Target_i386( std::string targetName ):
>>>     CID 1574966:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::TargetBase::TargetBase(std::__cxx11::string)" when it could be moved instead.
17         TargetBase( targetName )
18       {
19         conditionalBranchInstructions.push_back("ja");
20         conditionalBranchInstructions.push_back("jb");
21         conditionalBranchInstructions.push_back("jc");
22         conditionalBranchInstructions.push_back("je");

** CID 1574965:    (COPY_INSTEAD_OF_MOVE)
/rtemstoolkit/pkgconfig.cpp: 90 in pkgconfig::package::load(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()
/rtemstoolkit/pkgconfig.cpp: 92 in pkgconfig::package::load(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()


________________________________________________________________________________________________________
*** CID 1574965:    (COPY_INSTEAD_OF_MOVE)
/rtemstoolkit/pkgconfig.cpp: 90 in pkgconfig::package::load(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()
84     
85             if (d != std::string::npos)
86             {
87               std::string lhs = rld::tolower (line.substr (0, d));
88               std::string rhs = line.substr (d + 1);
89               if (def)
>>>     CID 1574965:    (COPY_INSTEAD_OF_MOVE)
>>>     "rhs" is copied in a call to copy assignment "operator =", when it could be moved instead.
90                 defines[lhs] = rhs;
91               else
92                 fields[lhs] = rhs;
93             }
94           }
95         }
/rtemstoolkit/pkgconfig.cpp: 92 in pkgconfig::package::load(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()
86             {
87               std::string lhs = rld::tolower (line.substr (0, d));
88               std::string rhs = line.substr (d + 1);
89               if (def)
90                 defines[lhs] = rhs;
91               else
>>>     CID 1574965:    (COPY_INSTEAD_OF_MOVE)
>>>     "rhs" is copied in a call to copy assignment "operator =", when it could be moved instead.
92                 fields[lhs] = rhs;
93             }
94           }
95         }
96     
97         in.close ();

** CID 1574964:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/covoar.cc: 142 in createBuildPath(std::__cxx11::list<Coverage::ExecutableInfo *, std::allocator<Coverage::ExecutableInfo *>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()


________________________________________________________________________________________________________
*** CID 1574964:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/covoar.cc: 142 in createBuildPath(std::__cxx11::list<Coverage::ExecutableInfo *, std::allocator<Coverage::ExecutableInfo *>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)()
136             for ( ; pri != eparts.rend(); ++pri )
137               bparts.insert(bparts.begin(), *pri);
138     
139             std::string thisBuildPath;
140             rld::path::path_join( thisBuildPath, bparts, thisBuildPath );
141             if ( buildPath.empty() ) {
>>>     CID 1574964:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "thisBuildPath" is copied in a call to copy assignment "operator =", when it could be moved instead.
142               buildPath = thisBuildPath;
143             } else {
144               if ( buildPath != thisBuildPath ) {
145                 fail = "executable build path does not match: " + buildPath;
146               }
147             }

** CID 1574963:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 757 in rld::exeinfo::func_count::func_count(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)()


________________________________________________________________________________________________________
*** CID 1574963:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 757 in rld::exeinfo::func_count::func_count(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)()
751         {
752           std::string name;
753           int         count;
754           size_t      size;
755     
756           func_count (std::string name, size_t size)
>>>     CID 1574963:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "name" is copied in call to copy constructor "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >", when it could be moved instead.
757             : name (name),
758               count (1),
759               size (size) {
760           }
761         };
762         typedef std::vector < func_count > func_counts;

** CID 1574962:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_powerpc.cc: 87 in Target::Target_powerpc_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574962:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_powerpc.cc: 87 in Target::Target_powerpc_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
81       }
82     
83       TargetBase *Target_powerpc_Constructor(
84         std::string          targetName
85       )
86       {
>>>     CID 1574962:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::Target_powerpc::Target_powerpc(std::__cxx11::string)" when it could be moved instead.
87         return new Target_powerpc( targetName );
88       }
89     

** CID 1574961:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_arm.cc: 129 in Target::Target_arm_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574961:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_arm.cc: 129 in Target::Target_arm_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
123       }
124     
125       TargetBase *Target_arm_Constructor(
126         std::string          targetName
127       )
128       {
>>>     CID 1574961:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::Target_arm::Target_arm(std::__cxx11::string)" when it could be moved instead.
129         return new Target_arm( targetName );
130       }
131     

** CID 1574960:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_riscv.cc: 81 in Target::Target_riscv_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574960:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_riscv.cc: 81 in Target::Target_riscv_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
75       }
76     
77       TargetBase *Target_riscv_Constructor(
78         std::string        targetName
79         )
80         {
>>>     CID 1574960:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::Target_riscv::Target_riscv(std::__cxx11::string)" when it could be moved instead.
81           return new Target_riscv( targetName );
82         }

** CID 1574959:  Insecure data handling  (TAINTED_SCALAR)


________________________________________________________________________________________________________
*** CID 1574959:  Insecure data handling  (TAINTED_SCALAR)
/rtemstoolkit/rld-elf.cpp: 562 in rld::elf::file::begin(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, int, bool, rld::elf::file*, long)()
556           writable = writable_;
557           elf_ = elf__;
558     
559           if (!archive && !writable)
560           {
561             load_header ();
>>>     CID 1574959:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted expression "this->ehdr" to "load_sections", which uses it as a loop boundary.
562             load_sections ();
563           }
564         }
565     
566         void
567         file::end ()

** CID 1574958:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 473 in rld::exeinfo::image::output_compilation_unit(bool, bool)()


________________________________________________________________________________________________________
*** CID 1574958:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 473 in rld::exeinfo::image::output_compilation_unit(bool, bool)()
467           std::cout << std::endl;
468     
469           if (objects)
470           {
471             std::cout << " Object files: " << cus.size () << std::endl;
472     
>>>     CID 1574958:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "common_flags" is copied in call to copy constructor "std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >", when it could be moved instead.
473             rld::strings filter_flags = common_flags;
474             filter_flags.insert (filter_flags.end (),
475                                  flag_exceptions.begin (),
476                                  flag_exceptions.end());
477     
478             for (auto& p : producers)

** CID 1574957:  Memory - illegal accesses  (UNINIT)
/rtemstoolkit/libiberty/cplus-dem.c: 196 in cplus_demangle()


________________________________________________________________________________________________________
*** CID 1574957:  Memory - illegal accesses  (UNINIT)
/rtemstoolkit/libiberty/cplus-dem.c: 196 in cplus_demangle()
190         {
191           ret = dlang_demangle (mangled, options);
192           if (ret)
193     	return ret;
194         }
195     
>>>     CID 1574957:  Memory - illegal accesses  (UNINIT)
>>>     Using uninitialized value "ret".
196       return (ret);
197     }
198     
199     /* Demangle ada names.  The encoding is documented in gcc/ada/exp_dbug.ads.  */
200     
201     char *

** CID 1574956:  Memory - corruptions  (ARRAY_VS_SINGLETON)


________________________________________________________________________________________________________
*** CID 1574956:  Memory - corruptions  (ARRAY_VS_SINGLETON)
/rtemstoolkit/SimpleIni.h: 2104 in CSimpleIniTempl<char, SI_GenericCase<char>, SI_ConvertA<char>>::AddEntry(const char *, const char *, const char *, const char *, bool, bool)()
2098                 // because we will be inserting the key next
2099                 rc = CopyString(a_pKey);
2100                 if (rc < 0) return rc;
2101             }
2102     
2103             // we always need a copy of the value
>>>     CID 1574956:  Memory - corruptions  (ARRAY_VS_SINGLETON)
>>>     Passing "a_pValue" via argument "a_pValue" to function "CopyString" which uses it as an array. This might corrupt or misinterpret adjacent memory locations.
2104             rc = CopyString(a_pValue);
2105             if (rc < 0) return rc;
2106         }
2107     
2108         // create the key entry
2109         if (iKey == keyval.end() || bForceCreateNewKey) {

** CID 1574955:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 1123 in main()


________________________________________________________________________________________________________
*** CID 1574955:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/linkers/rtems-exeinfo.cpp: 1123 in main()
1117         if (rld::verbose ())
1118           std::cout << "exe-image: " << exe_name << std::endl;
1119     
1120         /*
1121          * Open the executable and read the symbols.
1122          */
>>>     CID 1574955:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "exe_name" is passed-by-value as parameter to "rld::exeinfo::image::image(std::__cxx11::string, bool)" when it could be moved instead.
1123         rld::exeinfo::image exe (exe_name, inlined | dwarf_data);
1124     
1125         std::cout << "exe: " << exe.exe.name ().full () << std::endl
1126                   << std::endl;
1127     
1128         /*

** CID 1574954:  Error handling issues  (CHECKED_RETURN)
/tester/covoar/ObjdumpProcessor.cc: 187 in Coverage::ObjdumpProcessor::determineLoadAddress(Coverage::ExecutableInfo *)()


________________________________________________________________________________________________________
*** CID 1574954:  Error handling issues  (CHECKED_RETURN)
/tester/covoar/ObjdumpProcessor.cc: 187 in Coverage::ObjdumpProcessor::determineLoadAddress(Coverage::ExecutableInfo *)()
181             loadAddressFile.close();
182             std::ostringstream what;
183             what << "library " << Library << " not found in " << dlinfoName;
184             throw rld::error( what, METHOD );
185           }
186     
>>>     CID 1574954:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "sscanf" without checking return value (as is done elsewhere 5 out of 6 times).
187           sscanf( inputBuffer, "%s %x", inLibName, &offset );
188           std::string tmp = inLibName;
189           if ( tmp.find( Library ) != tmp.npos ) {
190             // std::cerr << inLibName << " - 0x"
191             //           << std::setfill( '0' ) << std::setw( 8 ) << std::hex
192             //           << offset << std::endl

** CID 1574953:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/rtemstoolkit/rld-rap.cpp: 770 in rld::rap::section_merge::operator ()(const rld::files::section &)()


________________________________________________________________________________________________________
*** CID 1574953:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/rtemstoolkit/rld-rap.cpp: 770 in rld::rap::section_merge::operator ()(const rld::files::section &)()
764           osection osec (fsec.name,
765                          offset,
766                          fsec.size,
767                          fsec.alignment,
768                          fsec.relocs.size (),
769                          fsec.flags);
>>>     CID 1574953:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "osec" is copied in a call to copy assignment "operator =", when it could be moved instead.
770           sec.osecs[fsec.index] = osec;
771           sec.osindexes.push_back (fsec.index);
772     
773           uint32_t rc = 0;
774     
775           for (files::relocations::const_iterator fri = fsec.relocs.begin ();

** CID 1574952:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/TraceConverter.cc: 161 in main()


________________________________________________________________________________________________________
*** CID 1574952:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/TraceConverter.cc: 161 in main()
155       }
156     
157     
158       // Create toolnames.
159       try
160       {
>>>     CID 1574952:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "cpuname" is passed-by-value as parameter to "TargetFactory" when it could be moved instead.
161         targetInfo.reset( Target::TargetFactory( cpuname ) );
162       }
163       catch ( rld::error re )
164       {
165         std::cerr << "error: "
166                   << re.where << ": " << re.what

** CID 1574951:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_lm32.cc: 18 in Target::Target_lm32::Target_lm32(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574951:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_lm32.cc: 18 in Target::Target_lm32::Target_lm32(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
12     #include <algorithm>
13     
14     namespace Target {
15     
16       // https://u15810271.ct.sendgrid.net/ls/click?upn=CTPegkVN6peWFCMEieYYmAy3X1jegPeWnxto7pNG35nvvR6RgfL-2BxTLFiyfH-2FOC7RuMZgjRkyIQlYzGf01lv2g-3D-3DMj6s_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMoZCjHFOqCXMwEVc6SqwIn97PDmxM63S-2FFgh4EjWtcEu2HzXYXkJEdG0NLSKmxVemnqfknEsTXPugQwOtXZ9mkY8TK6VA2UFg-2BOYwbZWjM0z-2Bln5XhNCdlq2gk97qRo71J7W2GvcHGFpSJ6miQs3m8ZprnW9v9RZ7tuasbQuq-2FlaA-3D-3D
17       Target_lm32::Target_lm32( std::string targetName ):
>>>     CID 1574951:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::TargetBase::TargetBase(std::__cxx11::string)" when it could be moved instead.
18         TargetBase( targetName )
19       {
20         conditionalBranchInstructions.push_back("be");
21         conditionalBranchInstructions.push_back("bge");
22         conditionalBranchInstructions.push_back("bgeu");
23         conditionalBranchInstructions.push_back("bg");

** CID 1574950:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_aarch64.cc: 21 in Target::Target_aarch64::Target_aarch64(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574950:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_aarch64.cc: 21 in Target::Target_aarch64::Target_aarch64(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
15     #include "qemu-traces.h"
16     #include "Target_aarch64.h"
17     
18     namespace Target {
19     
20       Target_aarch64::Target_aarch64( std::string targetName ):
>>>     CID 1574950:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::TargetBase::TargetBase(std::__cxx11::string)" when it could be moved instead.
21         TargetBase( targetName )
22       {
23         conditionalBranchInstructions.push_back("cbnz");
24         conditionalBranchInstructions.push_back("cbz");
25         conditionalBranchInstructions.push_back("tbnz");
26         conditionalBranchInstructions.push_back("tbz");

** CID 1574949:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_lm32.cc: 49 in Target::Target_lm32_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()


________________________________________________________________________________________________________
*** CID 1574949:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/Target_lm32.cc: 49 in Target::Target_lm32_Constructor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)()
43       }
44     
45       TargetBase *Target_lm32_Constructor(
46         std::string          targetName
47       )
48       {
>>>     CID 1574949:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetName" is passed-by-value as parameter to "Target::Target_lm32::Target_lm32(std::__cxx11::string)" when it could be moved instead.
49         return new Target_lm32( targetName );
50       }
51     

** CID 1574948:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/covoar.cc: 430 in covoar(int, char **)()


________________________________________________________________________________________________________
*** CID 1574948:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/tester/covoar/covoar.cc: 430 in covoar(int, char **)()
424       coverageFormat = Coverage::CoverageFormatToEnum( format );
425       coverageReader = Coverage::CreateCoverageReader( coverageFormat );
426       if ( !coverageReader ) {
427         throw rld::error( "Unable to create coverage file reader", "covoar" );
428       }
429     
>>>     CID 1574948:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "targetInfo" is copied in a call to copy assignment "operator =", when it could be moved instead.
430       coverageReader->targetInfo_m = targetInfo;
431     
432       // Prepare each executable for analysis.
433       for ( auto& exe : executablesToAnalyze ) {
434         if ( verbose ) {
435           std::cerr << "Extracting information from: " << exe->getFileName()

** CID 1574947:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/trace/record/record-client-base.cc: 139 in ConfigFile::INIHandler(void *, const char *, const char *, const char *)()


________________________________________________________________________________________________________
*** CID 1574947:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
/trace/record/record-client-base.cc: 139 in ConfigFile::INIHandler(void *, const char *, const char *, const char *)()
133       if (it != self->parser_.end()) {
134         std::string error = (*it->second.first)(it->second.second, name, value);
135         if (error == kNoError) {
136           return 1;
137         }
138     
>>>     CID 1574947:  Performance inefficiencies  (COPY_INSTEAD_OF_MOVE)
>>>     "error" is copied in a call to copy assignment "operator =", when it could be moved instead.
139         self->error_ = error;
140       } else {
141         self->error_ = std::string("unknown section: ") + section;
142       }
143     
144       return 0;


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQi8c7-2B1U0roIV5G3HXifs2sikLj2FV5O7uu1zqO3oUQQ-3DJMX2_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMoZCjHFOqCXMwEVc6SqwIn9iUujeP2-2FvH2W-2BaTs8uP-2FyvrXX3kmQgkb6jKrp2GUDjsE8jVBrSOviFosERuvH3MREUNrC0GdPbJImfoKpKH4-2FFKyiWixFtKWaf-2B69rWAMV0avMTibttRtUdwqrGllcjUiHRapWdoRvlSfwe6yqB9XQ-3D-3D



More information about the build mailing list