4040#include < errno.h>
4141#endif
4242
43+ // required for FD_ZERO
44+ using std::memset;
45+
4346ThreadExecutor::ThreadExecutor (const std::map<std::string, std::size_t > &files, Settings &settings, ErrorLogger &errorLogger)
4447 : _files(files), _settings(settings), _errorLogger(errorLogger), _fileCount(0 )
4548{
@@ -82,19 +85,19 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
8285
8386 if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) {
8487 std::cerr << " #### You found a bug from cppcheck.\n ThreadExecutor::handleRead error, type was:" << type << std::endl;
85- exit (0 );
88+ std:: exit (0 );
8689 }
8790
8891 unsigned int len = 0 ;
8992 if (read (rpipe, &len, sizeof (len)) <= 0 ) {
9093 std::cerr << " #### You found a bug from cppcheck.\n ThreadExecutor::handleRead error, type was:" << type << std::endl;
91- exit (0 );
94+ std:: exit (0 );
9295 }
9396
9497 char *buf = new char [len];
9598 if (read (rpipe, buf, len) <= 0 ) {
9699 std::cerr << " #### You found a bug from cppcheck.\n ThreadExecutor::handleRead error, type was:" << type << std::endl;
97- exit (0 );
100+ std:: exit (0 );
98101 }
99102
100103 if (type == REPORT_OUT) {
@@ -154,26 +157,26 @@ unsigned int ThreadExecutor::check()
154157 if (i != _files.end () && rpipes.size () < _settings._jobs ) {
155158 int pipes[2 ];
156159 if (pipe (pipes) == -1 ) {
157- std::cerr << " pipe() failed: " << strerror (errno) << std::endl;
158- exit (EXIT_FAILURE);
160+ std::cerr << " pipe() failed: " << std:: strerror (errno) << std::endl;
161+ std:: exit (EXIT_FAILURE);
159162 }
160163
161164 int flags = 0 ;
162165 if ((flags = fcntl (pipes[0 ], F_GETFL, 0 )) < 0 ) {
163- std::cerr << " fcntl(F_GETFL) failed: " << strerror (errno) << std::endl;
164- exit (EXIT_FAILURE);
166+ std::cerr << " fcntl(F_GETFL) failed: " << std:: strerror (errno) << std::endl;
167+ std:: exit (EXIT_FAILURE);
165168 }
166169
167170 if (fcntl (pipes[0 ], F_SETFL, flags | O_NONBLOCK) < 0 ) {
168- std::cerr << " fcntl(F_SETFL) failed: " << strerror (errno) << std::endl;
169- exit (EXIT_FAILURE);
171+ std::cerr << " fcntl(F_SETFL) failed: " << std:: strerror (errno) << std::endl;
172+ std:: exit (EXIT_FAILURE);
170173 }
171174
172175 pid_t pid = fork ();
173176 if (pid < 0 ) {
174177 // Error
175- std::cerr << " Failed to create child process: " << strerror (errno) << std::endl;
176- exit (EXIT_FAILURE);
178+ std::cerr << " Failed to create child process: " << std:: strerror (errno) << std::endl;
179+ std:: exit (EXIT_FAILURE);
177180 } else if (pid == 0 ) {
178181 close (pipes[0 ]);
179182 _wpipe = pipes[1 ];
@@ -193,7 +196,7 @@ unsigned int ThreadExecutor::check()
193196 std::ostringstream oss;
194197 oss << resultOfCheck;
195198 writeToPipe (CHILD_END, oss.str ());
196- exit (0 );
199+ std:: exit (0 );
197200 }
198201
199202 close (pipes[1 ]);
@@ -288,7 +291,7 @@ void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data)
288291 delete [] out;
289292 out = 0 ;
290293 std::cerr << " #### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
291- exit (0 );
294+ std:: exit (0 );
292295 }
293296
294297 delete [] out;
0 commit comments