@@ -107,7 +107,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
107107 bool warned = false ;
108108 std::vector<std::string> ignored = parser.GetIgnoredPaths ();
109109 std::vector<std::string>::iterator iterIgnored = ignored.begin ();
110- for (unsigned int i = ignored. size () - 1 ; i != UINT_MAX; --i ) {
110+ for (size_t i = 0 ; i < ignored. size (); ) {
111111 const std::string extension = Path::getFilenameExtension (ignored[i]);
112112 if (extension == " .h" || extension == " .hpp" ) {
113113 ignored.erase (iterIgnored + i);
@@ -116,12 +116,13 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
116116 std::cout << " cppcheck: Please use --suppress for ignoring results from the header files." << std::endl;
117117 warned = true ; // Warn only once
118118 }
119- }
119+ } else
120+ ++i;
120121 }
121122
122123 PathMatch matcher (parser.GetIgnoredPaths ());
123124 std::vector<std::string>::iterator iterBegin = filenames.begin ();
124- for (unsigned int i = filenames. size () - 1 ; i != UINT_MAX; i-- ) {
125+ for (size_t i = 0 ; i < filenames. size (); ) {
125126#if defined(_WIN32)
126127 // For Windows we want case-insensitive path matching
127128 const bool caseSensitive = false ;
@@ -130,6 +131,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
130131#endif
131132 if (matcher.Match (filenames[i], caseSensitive))
132133 filenames.erase (iterBegin + i);
134+ else
135+ ++i;
133136 }
134137 } else {
135138 std::cout << " cppcheck: error: could not find or open any of the paths given." << std::endl;
@@ -177,7 +180,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
177180 }
178181
179182 long processedsize = 0 ;
180- for (unsigned int c = 0 ; c < _filenames.size (); c++) {
183+ for (size_t c = 0 ; c < _filenames.size (); c++) {
181184 returnValue += cppCheck.check (_filenames[c]);
182185 if (_filesizes.find (_filenames[c]) != _filesizes.end ()) {
183186 processedsize += _filesizes[_filenames[c]];
@@ -269,13 +272,13 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
269272 }
270273}
271274
272- void CppCheckExecutor::reportStatus (unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal)
275+ void CppCheckExecutor::reportStatus (size_t fileindex, size_t filecount, long sizedone, long sizetotal)
273276{
274277 if (filecount > 1 ) {
275278 std::ostringstream oss;
276279 oss << fileindex << " /" << filecount
277280 << " files checked " <<
278- (sizetotal > 0 ? static_cast <long >(static_cast <double >(sizedone) / sizetotal*100 ) : 0 )
281+ (sizetotal > 0 ? static_cast <long >(static_cast <long double >(sizedone) / sizetotal*100 ) : 0 )
279282 << " % done" ;
280283 std::cout << oss.str () << std::endl;
281284 }
0 commit comments