diff --git a/CMakeLists.txt b/CMakeLists.txt index 51fc164c2..888962205 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,15 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() +set(_warning_flags "-Werror -Wall -Wextra -Wpedantic") +if(NOT CMAKE_C_FLAGS) + set(CMAKE_C_FLAGS ${_warning_flags}) +endif() + +if(NOT CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS ${_warning_flags}) +endif() + include(LanguageStandards) include(optimization) diff --git a/src/CmdLine.C b/src/CmdLine.C index 1b11914ee..c599a290f 100644 --- a/src/CmdLine.C +++ b/src/CmdLine.C @@ -811,7 +811,7 @@ static void disableUnwantedTests(std::vector &groups) if (unique_id && max_unique_id && testLimit) { unsigned cur_test = 0; - unsigned cur_test_limitgroup = 0; + int cur_test_limitgroup = 0; for (unsigned i=0; i < groups.size(); i++) { if (groups[i]->disabled) continue; @@ -833,7 +833,7 @@ static void disableUnwantedTests(std::vector &groups) } else if (unique_id && max_unique_id && groupLimit) { unsigned cur_group = 0; - unsigned cur_limitgroup = 0; + int cur_limitgroup = 0; for (unsigned i=0; i < groups.size(); i++) { if (groups[i]->disabled) continue; @@ -916,7 +916,7 @@ static void disableUnwantedTests(std::vector &groups) } if (given_mutator != -1) { for (unsigned i = 0; i < groups.size(); i++) { - if (i != given_mutator && !groups[i]->disabled) { + if (static_cast(i) != given_mutator && !groups[i]->disabled) { for (unsigned j=0; jtests.size(); j++) { if (!groups[i]->tests[j]->disabled) { @@ -988,8 +988,6 @@ static bool mutateeListContains(std::vector mutatee_list, const char *mu // don't match. All tests start out enabled, and we previously disabled any // that are crashing while we were parsing the resume log. static bool testListContains(TestInfo * test, std::vector &testsn) { - bool match_found = false; - for (size_t i = 0; i < testsn.size(); i++) { if (nameMatches(testsn[i], test->name)) return true; diff --git a/src/DatabaseOutputDriver.C b/src/DatabaseOutputDriver.C index c9bdfda55..59c9a5d15 100644 --- a/src/DatabaseOutputDriver.C +++ b/src/DatabaseOutputDriver.C @@ -65,8 +65,8 @@ extern "C" { DatabaseOutputDriver::DatabaseOutputDriver(void * data) : attributes(NULL), - submittedResults(false), wroteLogHeader(false), + submittedResults(false), currTest(NULL), result(UNKNOWN) { @@ -89,7 +89,7 @@ DatabaseOutputDriver::~DatabaseOutputDriver() { void DatabaseOutputDriver::startNewTest(std::map &attrs, - TestInfo *test, RunGroup *group) + TestInfo *test, RunGroup *) { currTest = test; @@ -116,11 +116,11 @@ DatabaseOutputDriver::startNewTest(std::map &attrs, result = UNKNOWN; } -void DatabaseOutputDriver::redirectStream(TestOutputStream stream, const char * filename) { +void DatabaseOutputDriver::redirectStream(TestOutputStream, const char *) { // This is a no-op for database output } -void DatabaseOutputDriver::logResult(test_results_t res, int stage) { +void DatabaseOutputDriver::logResult(test_results_t res, int) { // What does this do, exactly? Store the result code for database check-in // I guess.. // Do I want to submit the results to the database in this method, or use @@ -128,7 +128,7 @@ void DatabaseOutputDriver::logResult(test_results_t res, int stage) { result = res; } -void DatabaseOutputDriver::logCrash(std::string crashedTest) { +void DatabaseOutputDriver::logCrash(std::string) { // New idea: we've already called startNewTest for this test, so // dblogFilename is set to recover the old log data for the test. // All we need to do is register a crashed result for the test. @@ -142,7 +142,7 @@ void DatabaseOutputDriver::log(TestOutputStream stream, const char *fmt, ...) { va_end(args); } -void DatabaseOutputDriver::vlog(TestOutputStream stream, const char *fmt, +void DatabaseOutputDriver::vlog(TestOutputStream, const char *fmt, va_list args) { FILE *dbout = NULL; @@ -245,7 +245,7 @@ void DatabaseOutputDriver::finalizeOutput() { __FILE__, __LINE__, sqlLogFilename.c_str()); //TODO handle error } - int size = strlen(logHeader.c_str()); + auto size = strlen(logHeader.c_str()); if (fwrite(logHeader.c_str(), sizeof(char), size, sqlLog) != size) { fprintf(stderr, "[%s:%u] - Error writing to log file.\n", __FILE__, __LINE__); //TODO handle error diff --git a/src/MutateeStart.C b/src/MutateeStart.C index 0d0f03306..e4da2b7fa 100644 --- a/src/MutateeStart.C +++ b/src/MutateeStart.C @@ -222,7 +222,6 @@ static std::string launchMutatee_plat(const std::string &exec_name, const std::v setenv("LD_LIBRARY_PATH", new_ld_path, 1); char **argv = getCParams(exec_name, args); - const char *c_exec_name = exec_name.c_str(); execvp(exec_name.c_str(), (char * const *) argv); @@ -385,7 +384,7 @@ static std::string launchMutatee_plat(const std::string &exec_name, const std::v } #endif -bool shouldLaunch(RunGroup *group, ParameterDict ¶ms) +bool shouldLaunch(RunGroup *, ParameterDict &) { return true; } @@ -395,7 +394,6 @@ std::string launchMutatee(std::string executable, std::vector &args char group_num[32]; snprintf(group_num, 32, "%d", group->index); - bool in_runtests = params["in_runtests"]->getInt(); if (!shouldLaunch(group, params)) return std::string(group_num) + ":-1"; @@ -542,7 +540,7 @@ Dyninst::PID getMutateePid(RunGroup *group) int pid; sscanf(mutatee_string.c_str(), "%d:%d", &group_id, &pid); - assert(group->index == group_id || group_id == -1); + assert(group->index == static_cast(group_id) || group_id == -1); spawned_mutatees.erase(i); diff --git a/src/ParameterDict.C b/src/ParameterDict.C index b40f37e9e..c4fea5953 100644 --- a/src/ParameterDict.C +++ b/src/ParameterDict.C @@ -44,7 +44,7 @@ Parameter::~Parameter() } // Error functions, in proper operation these will be overidden in a subclass -void Parameter::setString(const char *str) +void Parameter::setString(const char *) { fprintf(stderr, "Warning: Setting a string for a non-string Parameter, ignored\n"); } @@ -61,7 +61,7 @@ int Parameter::getInt() return -1; } -void Parameter::setInt(int num) +void Parameter::setInt(int) { fprintf(stderr, "Warning: Setting an int for a non-int Parameter, ignored\n"); } @@ -72,7 +72,7 @@ void *Parameter::getPtr() return NULL; } -void Parameter::setPtr(void *ptr) +void Parameter::setPtr(void *) { fprintf(stderr, "Warning: Setting an ptr for a non-ptr Parameter, ignored\n"); } diff --git a/src/ResumeLog.C b/src/ResumeLog.C index 38ac6a4ad..0fef56f02 100644 --- a/src/ResumeLog.C +++ b/src/ResumeLog.C @@ -170,13 +170,13 @@ void parse_resumelog(std::vector &groups) for (;;) { - int res = fscanf(f, "%d,%d,%d\n", &groupnum, &testnum, &runstate_int); + int res = fscanf(f, "%u,%u,%d\n", &groupnum, &testnum, &runstate_int); if (res != 3) break; - assert(groupnum >= 0 && groupnum < groups.size()); + assert(static_cast(groupnum) < groups.size()); assert(groups[groupnum]); - assert(testnum >= 0); + assert(testnum >= 0UL); assert(testnum < groups[groupnum]->tests.size()); if (runstate_int == RESULT_REPORTED) { diff --git a/src/StdOutputDriver.C b/src/StdOutputDriver.C index ea2f0e8e6..f48fb4c27 100644 --- a/src/StdOutputDriver.C +++ b/src/StdOutputDriver.C @@ -44,15 +44,12 @@ #include #include -StdOutputDriver::StdOutputDriver(void * data) : attributes(NULL), streams() { +StdOutputDriver::StdOutputDriver(void *) { streams[STDOUT] = std::string("-"); streams[STDERR] = std::string("-"); streams[LOGINFO] = std::string("-"); streams[LOGERR] = std::string("-"); streams[HUMAN] = std::string("-"); - last_test = NULL; - last_group = NULL; - printed_header = false; } StdOutputDriver::~StdOutputDriver() { @@ -257,7 +254,7 @@ FILE *StdOutputDriver::getHumanFile() { return out; } -void StdOutputDriver::logCrash(std::string testname) { +void StdOutputDriver::logCrash(std::string) { // TODO Do something here } @@ -281,7 +278,7 @@ void StdOutputDriver::vlog(TestOutputStream stream, const char *fmt, va_list arg } const char *fn = streams[stream].c_str(); - FILE *out; + FILE *out{}; if (strcmp(fn, "-") == 0) { // We're printing to the default file switch(stream) { @@ -295,6 +292,8 @@ void StdOutputDriver::vlog(TestOutputStream stream, const char *fmt, va_list arg case LOGERR: out = stderr; break; + case OUTPUT_STREAMS_SIZE: + break; } } else { // Open the file diff --git a/src/StdOutputDriver.h b/src/StdOutputDriver.h index a1a82c5c9..0fc78c859 100644 --- a/src/StdOutputDriver.h +++ b/src/StdOutputDriver.h @@ -39,10 +39,10 @@ class StdOutputDriver : public TestOutputDriver { protected: - std::map streams; - std::map *attributes; - TestInfo *last_test; - RunGroup *last_group; + std::map streams{}; + std::map *attributes{}; + TestInfo *last_test{}; + RunGroup *last_group{}; //Column widths static const int name_len = 26; @@ -55,7 +55,7 @@ class StdOutputDriver : public TestOutputDriver { static const int pic_len = 7; static const int pmode_len = 5; - bool printed_header; + bool printed_header{false}; void printHeader(FILE *out); public: TESTLIB_DLL_EXPORT StdOutputDriver(void * data); diff --git a/src/TestMutator.C b/src/TestMutator.C index 02bc6152d..b6e994986 100644 --- a/src/TestMutator.C +++ b/src/TestMutator.C @@ -44,7 +44,7 @@ bool TestMutator::hasCustomExecutionPath() { return false; } -test_results_t TestMutator::setup(ParameterDict ¶m) { +test_results_t TestMutator::setup(ParameterDict &) { return PASSED; } diff --git a/src/TestOutputDriver.C b/src/TestOutputDriver.C index aa5ef428d..bd20ee299 100644 --- a/src/TestOutputDriver.C +++ b/src/TestOutputDriver.C @@ -94,7 +94,7 @@ static void parseLabel3(std::map *attrs, } TESTLIB_DLL_EXPORT bool TestOutputDriver::getAttributesMap(TestInfo *test, - RunGroup *group, std::map &attrs) { + RunGroup *, std::map &attrs) { if ((NULL == test) || (NULL == test->label)) { return false; } diff --git a/src/UsageMonitor.h b/src/UsageMonitor.h index 0f33d53c4..1f0d4e866 100644 --- a/src/UsageMonitor.h +++ b/src/UsageMonitor.h @@ -29,6 +29,7 @@ class UsageMonitor public: TESTLIB_DLL_EXPORT UsageMonitor(); + TESTLIB_DLL_EXPORT UsageMonitor(UsageMonitor const&) = default; TESTLIB_DLL_EXPORT void start(); TESTLIB_DLL_EXPORT void end(); TESTLIB_DLL_EXPORT void clear(); diff --git a/src/connection.C b/src/connection.C index 827c7282b..a9c453cd3 100644 --- a/src/connection.C +++ b/src/connection.C @@ -163,6 +163,7 @@ bool Connection::recv_return(char* &buffer) { handle_message(msg+2); } } + return false; } int Connection::sockfd = -1; @@ -216,11 +217,6 @@ bool Connection::hasError() #define SOCKTYPE_UNIX -#if defined(CONNECTION_DEBUG) -#define debug_printf(str, ...) do { if (getDebugLog()) { fprintf(getDebugLog(), str, ## __VA_ARGS__); fflush(getDebugLog()); } } while (0) -#else -#define debug_printf(str, args...) -#endif #include #include #include @@ -240,31 +236,17 @@ bool Connection::send_message(MessageBuffer &buffer) ssize_t result = send(fd, &msg_size, sizeof(uint32_t), 0); if (result == -1) { - debug_printf("[%s:%u] - Error sending data count on socket\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Error sending data count on socket\n", __FILE__, __LINE__); return false; } - debug_printf("[%d] - Send size of %lu, (encoded 0x%lx)\n", + fprintf(stderr,"[%d] - Send size of %lu, (encoded 0x%lx)\n", getpid(), (unsigned long) msg_size_unenc, (unsigned long) msg_size); result = send(fd, buffer.get_buffer(), msg_size_unenc, 0); if (result == -1) { - debug_printf("[%s:%u] - Error sending raw data on socket\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Error sending raw data on socket\n", __FILE__, __LINE__); return false; } -#if defined(CONNECTION_DEBUG) - if (getDebugLog()) { - debug_printf("[%d] - Sent buffer ", getpid()); - char *c = buffer.get_buffer(); - for (unsigned i=0; i= 1) { @@ -384,6 +352,7 @@ bool Connection::waitForAvailData(int sock, int timeout_s, bool &sock_error) assert(0); } } + return false; } bool Connection::server_accept() @@ -392,7 +361,7 @@ bool Connection::server_accept() socklen_t socklen = sizeof(struct sockaddr_in); bool sock_error; - debug_printf("[%s:%u] - server_accept waiting for connection\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - server_accept waiting for connection\n", __FILE__, __LINE__); if (!waitForAvailData(sockfd, accept_timeout, sock_error)) return false; @@ -400,26 +369,26 @@ bool Connection::server_accept() fd = accept(sockfd, (sockaddr *) &addr, &socklen); if (fd == -1) { - debug_printf("[%s:%u] - Error accepting connection\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Error accepting connection\n", __FILE__, __LINE__); return false; } - debug_printf("server_accept recieved new connection on fd %d\n", fd); + fprintf(stderr,"server_accept recieved new connection on fd %d\n", fd); return true; } bool Connection::client_connect() { - debug_printf("Trying client_connect to %s:%d\n", hostname.c_str(), port); + fprintf(stderr,"Trying client_connect to %s:%d\n", hostname.c_str(), port); assert(has_hostport); fd = socket(PF_INET, SOCK_STREAM, 0); if (fd == -1) { - debug_printf("Unable to create client socket: %s\n", strerror(errno)); + fprintf(stderr,"Unable to create client socket: %s\n", strerror(errno)); return false; } - debug_printf("Trying to get hostname for %s\n", hostname.c_str()); + fprintf(stderr,"Trying to get hostname for %s\n", hostname.c_str()); struct addrinfo *ai, *p; struct addrinfo hints; @@ -431,13 +400,13 @@ bool Connection::client_connect() string portstr = std::to_string(port); if (getaddrinfo(hostname.c_str(), portstr.c_str(), &hints, &ai)) { - debug_printf("Error looking up hostname %s\n", hostname.c_str()); + fprintf(stderr,"Error looking up hostname %s\n", hostname.c_str()); return false; } - debug_printf("Got a size %d address for hostname %s\n", ai->ai_addrlen, hostname.c_str()); + fprintf(stderr,"Got a size %d address for hostname %s\n", ai->ai_addrlen, hostname.c_str()); if (ai == NULL) { - debug_printf("No addresses with hostname %s\n", hostname.c_str()); + fprintf(stderr,"No addresses with hostname %s\n", hostname.c_str()); return false; } @@ -459,22 +428,22 @@ bool Connection::client_connect() inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr); result = connect(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)); } - debug_printf("Connecting to %s:%u\n", ipstr, port); + fprintf(stderr,"Connecting to %s:%u\n", ipstr, port); } if (result == -1) { - debug_printf("[%s:%u] - Error connecting to server\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Error connecting to server\n", __FILE__, __LINE__); return false; } - debug_printf("Successfully connected to %s\n", hostname.c_str()); + fprintf(stderr,"Successfully connected to %s\n", hostname.c_str()); return true; } bool Connection::server_setup(string &hostname_, int &port_) { if (has_hostport) { - debug_printf("server_setup returning existing hostname/port %s/%d", + fprintf(stderr,"server_setup returning existing hostname/port %s/%d", hostname.c_str(), port); hostname_ = hostname; port_ = port; @@ -484,10 +453,10 @@ bool Connection::server_setup(string &hostname_, int &port_) sockfd = socket(PF_INET, SOCK_STREAM, 0); if (sockfd == -1) { - debug_printf("Unable to create socket: %s\n", strerror(errno)); + fprintf(stderr,"Unable to create socket: %s\n", strerror(errno)); return false; } - debug_printf("server_setup socket call returned %d\n", sockfd); + fprintf(stderr,"server_setup socket call returned %d\n", sockfd); struct sockaddr_in addr; socklen_t socklen = sizeof(struct sockaddr_in); @@ -499,21 +468,21 @@ bool Connection::server_setup(string &hostname_, int &port_) int result = ::bind(sockfd, (struct sockaddr *) &addr, socklen); if (result != 0){ - debug_printf("Unable to bind socket: %s\n", strerror(errno)); + fprintf(stderr,"Unable to bind socket: %s\n", strerror(errno)); return false; } - debug_printf("[%s:%u] - server_setup successful bind on socket\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - server_setup successful bind on socket\n", __FILE__, __LINE__); result = listen(sockfd, 16); if (result == -1) { - debug_printf("Unable to listen on socket: %s\n", strerror(errno)); + fprintf(stderr,"Unable to listen on socket: %s\n", strerror(errno)); return false; } - debug_printf("[%s:%u] - server_setup successful listen on socket\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - server_setup successful listen on socket\n", __FILE__, __LINE__); result = getsockname(sockfd, (sockaddr *) &addr, &socklen); if (result != 0) { - debug_printf("[%s:%u] - Unable to getsockname on socket\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Unable to getsockname on socket\n", __FILE__, __LINE__); return false; } @@ -525,7 +494,7 @@ bool Connection::server_setup(string &hostname_, int &port_) char name_buffer[1024]; result = gethostname(name_buffer, 1024); if (result != 0) { - debug_printf("[%s:%u] - Unable to get hostname\n", __FILE__, __LINE__); + fprintf(stderr,"[%s:%u] - Unable to get hostname\n", __FILE__, __LINE__); return false; } hostname = name_buffer; @@ -537,7 +506,7 @@ bool Connection::server_setup(string &hostname_, int &port_) port_ = port; has_hostport = true; - debug_printf("[%s:%u] - server_setup returning new hostname/port %s/%d\n", + fprintf(stderr,"[%s:%u] - server_setup returning new hostname/port %s/%d\n", __FILE__, __LINE__, hostname.c_str(), port); return true; } diff --git a/src/dyninst/Callbacks.C b/src/dyninst/Callbacks.C index 29725edfd..232ef4a06 100644 --- a/src/dyninst/Callbacks.C +++ b/src/dyninst/Callbacks.C @@ -89,9 +89,10 @@ void errorFunc(BPatchErrorLevel level, int num, const char * const *params) if ( expectErrors ) { dprintf("Error (expected) #%d (level %d): %s\n", num, level, line); } else { - if(num != 112) + if(num != 112) { if ( errorPrint ) printf("Error #%d (level %d): %s\n", num, level, line); + } // We consider some errors fatal. if (num == 101) { diff --git a/src/dyninst/cpp_test.h b/src/dyninst/cpp_test.h index af08ef050..96fa74c9e 100644 --- a/src/dyninst/cpp_test.h +++ b/src/dyninst/cpp_test.h @@ -135,7 +135,7 @@ class namespace_test : public cpp_test_util private : - int class_variable; + int class_variable{}; }; class exception_test : public cpp_test_util diff --git a/src/dyninst/dyninst_comp.C b/src/dyninst/dyninst_comp.C index bd891a288..00e78f42d 100644 --- a/src/dyninst/dyninst_comp.C +++ b/src/dyninst/dyninst_comp.C @@ -53,25 +53,25 @@ using namespace std; class DyninstComponent : public ComponentTester { private: - BPatch *bpatch; - char *libRTname; - char *libRTname_m_abi; - std::string err_msg; - - ParamPtr bpatch_ptr; - ParamPtr bp_appThread; - ParamPtr bp_appAddrSpace; - ParamPtr bp_appProc; - ParamPtr bp_appBinEdit; - - ParamInt is_xlc; - BPatch_thread *appThread; - BPatch_addressSpace *appAddrSpace; - BPatch_process *appProc; - BPatch_binaryEdit *appBinEdit; + BPatch *bpatch{}; + char *libRTname{}; + char *libRTname_m_abi{}; + std::string err_msg{}; + + ParamPtr bpatch_ptr{}; + ParamPtr bp_appThread{}; + ParamPtr bp_appAddrSpace{}; + ParamPtr bp_appProc{}; + ParamPtr bp_appBinEdit{}; + + ParamInt is_xlc{false}; + BPatch_thread *appThread{}; + BPatch_addressSpace *appAddrSpace{}; + BPatch_process *appProc{}; + BPatch_binaryEdit *appBinEdit{}; public: - DyninstComponent(); + DyninstComponent() = default; virtual test_results_t program_setup(ParameterDict ¶ms); virtual test_results_t program_teardown(ParameterDict ¶ms); virtual test_results_t group_setup(RunGroup *group, ParameterDict ¶ms); @@ -81,21 +81,12 @@ public: virtual std::string getLastErrorMsg(); - virtual ~DyninstComponent(); + virtual ~DyninstComponent() = default; }; bool isMutateeMABI32(const char *name); bool isMutateeXLC(const char *name); -DyninstComponent::DyninstComponent() : - bpatch(NULL), - libRTname(NULL), - libRTname_m_abi(NULL), - bp_appThread(NULL), - is_xlc(0), - appThread(NULL) -{ -} test_results_t DyninstComponent::program_setup(ParameterDict ¶ms) { @@ -140,7 +131,7 @@ test_results_t DyninstComponent::program_setup(ParameterDict ¶ms) return PASSED; } -test_results_t DyninstComponent::program_teardown(ParameterDict ¶ms) +test_results_t DyninstComponent::program_teardown(ParameterDict &) { delete bpatch; bpatch = NULL; @@ -338,9 +329,7 @@ test_results_t DyninstComponent::group_teardown(RunGroup *group, return PASSED; } - bool mutateeExitedViaSignal = false; if(appProc->terminationStatus() == ExitedViaSignal) { - mutateeExitedViaSignal = true; int signalNum = appProc->getExitSignal(); getOutput()->log(LOGINFO, "Mutatee exited from signal 0x%x\n", signalNum); } @@ -354,12 +343,12 @@ test_results_t DyninstComponent::group_teardown(RunGroup *group, return UNKNOWN; } -test_results_t DyninstComponent::test_setup(TestInfo *test, ParameterDict &parms) +test_results_t DyninstComponent::test_setup(TestInfo *, ParameterDict &) { return PASSED; } -test_results_t DyninstComponent::test_teardown(TestInfo *test, ParameterDict &parms) +test_results_t DyninstComponent::test_teardown(TestInfo *test, ParameterDict &) { // Take care of the things the test can delete out from under us DyninstMutator* theMutator = dynamic_cast(test->mutator); @@ -414,23 +403,6 @@ COMPLIB_DLL_EXPORT ComponentTester *componentTesterFactory() { return new DyninstComponent(); } -DyninstComponent::~DyninstComponent() -{ -} - -// All the constructor does is set the instance fields to NULL -DyninstMutator::DyninstMutator() : - appThread(NULL), - appAddrSpace(NULL), - appBinEdit(NULL), - appProc(NULL), - appImage(NULL) -{ -} - -DyninstMutator::~DyninstMutator() { -} - // Standard setup; this does the setup for the "simple" class of tests. // "Simple" tests are tests that only perform any processing in the executeTest // stage. Most just do some lookup in the mutatee and then optionally insert @@ -1256,7 +1228,7 @@ int instEffAddr(BPatch_addressSpace* as, const char* fname, } else { - for(int i = 0; i < (*res2).size(); i++) + for(unsigned int i = 0; i < (*res2).size(); i++) { BPatch_Vector listArgs2; std::string insn = (*res2)[i]->getInsnAtPoint().format(); @@ -1377,13 +1349,13 @@ bool hasExtraUnderscores(const char *str) /* WARNING: This function is not thread safe. */ const char *fixUnderscores(const char *str) { - static char buf[256]; + static char buf[256]{}; assert( str ); assert( strlen(str) < sizeof(buf) ); while (*str == '_') ++str; - strncpy(buf, str, 256); + strncpy(buf, str, 255); char *ptr = buf + strlen(buf) - 1; while (ptr > buf && *ptr == '_') *(ptr--) = 0; @@ -1582,7 +1554,7 @@ int letOriginalMutateeFinish(BPatch_process *appThread){ while( !appThread->isTerminated()); - int retVal; + int retVal{}; if(appThread->terminationStatus() == ExitedNormally) { retVal = appThread->getExitCode(); diff --git a/src/dyninst/dyninst_comp.h b/src/dyninst/dyninst_comp.h index 664bdbea5..4ad6d1f8e 100644 --- a/src/dyninst/dyninst_comp.h +++ b/src/dyninst/dyninst_comp.h @@ -41,19 +41,19 @@ // Base class for the mutator part of a test class COMPLIB_DLL_EXPORT DyninstMutator : public TestMutator { public: - BPatch_thread *appThread; - BPatch_addressSpace *appAddrSpace; - BPatch_binaryEdit *appBinEdit; - BPatch_process *appProc; + BPatch_thread *appThread{}; + BPatch_addressSpace *appAddrSpace{}; + BPatch_binaryEdit *appBinEdit{}; + BPatch_process *appProc{}; // FIXME This field (appImage) probably isn't necessary. It looks looks like // appImage is easily derivable from appThread. - BPatch_image *appImage; + BPatch_image *appImage{}; - create_mode_t runmode; + create_mode_t runmode{}; - DyninstMutator(); + DyninstMutator() = default; virtual test_results_t setup(ParameterDict ¶m); - virtual ~DyninstMutator(); + virtual ~DyninstMutator() = default; }; extern "C" { TEST_DLL_EXPORT TestMutator *TestMutator_factory(); diff --git a/src/dyninst/init_fini_callback.C b/src/dyninst/init_fini_callback.C index 13cf67df1..e3de6fe82 100644 --- a/src/dyninst/init_fini_callback.C +++ b/src/dyninst/init_fini_callback.C @@ -120,7 +120,6 @@ test_results_t init_fini_callback_Mutator::executeTest() BPatch_Vector appModules; appImage->getObjects(appModules); char buffer[80] = {}; - test_results_t pass_fail = PASSED; bool init_libtesta = false; bool fini_libtesta = false; diff --git a/src/dyninst/snip_change_shlib_var.C b/src/dyninst/snip_change_shlib_var.C index 8d60a85a4..5f1954bf7 100644 --- a/src/dyninst/snip_change_shlib_var.C +++ b/src/dyninst/snip_change_shlib_var.C @@ -170,9 +170,9 @@ test_results_t snip_change_shlib_var_Mutator::executeTest() bool isStatic = appAddrSpace->isStaticExecutable(); - strncpy(libNameA, libNameAroot, 128); + memcpy(libNameA, libNameAroot, 128); addLibArchExt(libNameA,128, pointer_size, isStatic); - strncpy(libNameB, libNameBroot, 128); + memcpy(libNameB, libNameBroot, 128); addLibArchExt(libNameB,128, pointer_size, isStatic); char libA[128], libB[128]; diff --git a/src/dyninst/snip_ref_shlib_var.C b/src/dyninst/snip_ref_shlib_var.C index ec860268d..2bfd6f9c9 100644 --- a/src/dyninst/snip_ref_shlib_var.C +++ b/src/dyninst/snip_ref_shlib_var.C @@ -126,7 +126,6 @@ test_results_t snip_ref_shlib_var_Mutator::mutatorTest() { // The check function returns 1 on success (value changed as expected) // or 0 on failure. - const char *check_fname = "check_snip_ref_shlib_var"; const char *inst_func_name = "srsv1"; BPatch_Vector funcs; @@ -205,9 +204,9 @@ test_results_t snip_ref_shlib_var_Mutator::executeTest() #endif bool isStatic = appAddrSpace->isStaticExecutable(); - strncpy(libNameA, libNameAroot, 128); + memcpy(libNameA, libNameAroot, 128); addLibArchExt(libNameA,128, pointer_size, isStatic); - strncpy(libNameB, libNameBroot, 128); + memcpy(libNameB, libNameBroot, 128); addLibArchExt(libNameB,128, pointer_size, isStatic); char libA[128], libB[128]; diff --git a/src/dyninst/test1.h b/src/dyninst/test1.h index ac58c7981..9fb370648 100644 --- a/src/dyninst/test1.h +++ b/src/dyninst/test1.h @@ -33,8 +33,8 @@ unsigned long get_pointer() { - unsigned long val; - for(short i = 0; i < sizeof(void *); i++) { + unsigned long val = 0UL; + for(short i = 0; i < (short)(sizeof(void *)); i++) { val = (val << 8)|((i&0xFF)|0xA0); } return val; diff --git a/src/dyninst/test1_20.C b/src/dyninst/test1_20.C index 5a2c91396..a17701e09 100644 --- a/src/dyninst/test1_20.C +++ b/src/dyninst/test1_20.C @@ -106,7 +106,6 @@ test_results_t test1_20_Mutator::executeTest() return FAILED; } - BPatch_point *p = NULL; bool found_one = false; /* We expect certain errors from createInstPointAtAddr. */ diff --git a/src/dyninst/test1_22.C b/src/dyninst/test1_22.C index 56cc99f8b..0eada6612 100644 --- a/src/dyninst/test1_22.C +++ b/src/dyninst/test1_22.C @@ -83,7 +83,6 @@ extern "C" DLLEXPORT TestMutator *test1_22_factory() test_results_t test1_22_Mutator::mutatorTest22() { - char errbuf[1024]; errbuf[0] = '\0'; BPatch_object *modA = NULL; BPatch_object *modB = NULL; diff --git a/src/dyninst/test1_30.C b/src/dyninst/test1_30.C index bde5e17de..fe3088a9c 100644 --- a/src/dyninst/test1_30.C +++ b/src/dyninst/test1_30.C @@ -66,8 +66,6 @@ test_results_t test1_30_Mutator::executeTest() { unsigned long n; unsigned long baseAddr,lastAddr; unsigned int call30_1_line_no; - unsigned short lineNo; - char fileName[256]; if (isMutateeFortran(appImage)) { return SKIPPED; diff --git a/src/dyninst/test1_37.C b/src/dyninst/test1_37.C index ff641cdb4..daf3f7225 100644 --- a/src/dyninst/test1_37.C +++ b/src/dyninst/test1_37.C @@ -62,21 +62,6 @@ extern "C" DLLEXPORT TestMutator *test1_37_factory() // Start Test Case #37 - (loop instrumentation) // -// sort basic blocks ascending by block number -static void sort_blocks(BPatch_Vector &a, int n) -{ - for (int i=0; igetBlockNumber() < a[j]->getBlockNumber()) - { - BPatch_basicBlock* tmp = a[j]; - a[j] = a[j+1]; - a[j+1] = tmp; - } - } -} - /* This method instruments the entry and exit edges of a loop with the passed-in function. It accomplishes this by looking up the entry and exit blocks of the loop, finding the edges that do not come from diff --git a/src/dyninst/test1_41.C b/src/dyninst/test1_41.C index 00052998e..181c0f564 100644 --- a/src/dyninst/test1_41.C +++ b/src/dyninst/test1_41.C @@ -40,36 +40,33 @@ #include "BPatch_thread.h" #include "BPatch_snippet.h" #include "BPatch_statement.h" - #include "test_lib.h" - #include "dyninst_comp.h" + +#include + + class test1_41_Mutator : public DyninstMutator { - BPatch_exitType expectedSignal; - int debugPrint; - const int iterations; - char *pathname; - BPatch *bpatch; + BPatch_exitType expectedSignal{ExitedNormally}; + int debugPrint{}; + const int iterations{2}; + char *pathname{}; + BPatch *bpatch{}; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); public: - test1_41_Mutator(); + test1_41_Mutator() = default; }; extern "C" DLLEXPORT TestMutator *test1_41_factory() { return new test1_41_Mutator(); } -test1_41_Mutator::test1_41_Mutator() - : expectedSignal(ExitedNormally), iterations(2) { - TestMutator(); -} - // static int mutatorTest(char *pathname, BPatch *bpatch) test_results_t test1_41_Mutator::executeTest() { - unsigned int n=0; + int n=0; const char *child_argv[5]; child_argv[n++] = pathname; if (debugPrint) child_argv[n++] = const_cast("-verbose"); @@ -77,7 +74,7 @@ test_results_t test1_41_Mutator::executeTest() { child_argv[n++] = const_cast("test1_41"); // run test41 in mutatee child_argv[n++] = NULL; - int counts[iterations]; + std::vector counts(iterations); // Run the mutatee twice, querying line info each time & store the info for (n = 0; n < iterations; n++) { diff --git a/src/dyninst/test2_7.C b/src/dyninst/test2_7.C index b54fbad6c..428e46ec2 100644 --- a/src/dyninst/test2_7.C +++ b/src/dyninst/test2_7.C @@ -54,6 +54,7 @@ extern "C" DLLEXPORT TestMutator *test2_7_factory() { return new test2_7_Mutator(); } +#if defined(os_windows_test) static void lcase(char *s) { while (*s) { if (*s >= 'A' && *s <= 'Z') @@ -61,6 +62,7 @@ static void lcase(char *s) { s++; } } +#endif // static int mutatorTest(BPatch_thread *thread, BPatch_image *img) test_results_t test2_7_Mutator::executeTest() { @@ -90,8 +92,8 @@ test_results_t test2_7_Mutator::executeTest() { BPatch_Vector obj; appImage->getObjects(obj); for (auto i = obj.begin(); i != obj.end(); i++) { - char name[80]; - strncpy(name, (*i)->name().c_str(), 80); + char name[80]{}; + strncpy(name, (*i)->name().c_str(), sizeof(name) - 1UL); #if defined(os_windows_test) //Windows files don't have case sensitive names, so make //sure we have a consistent name. diff --git a/src/dyninst/test3_3.C b/src/dyninst/test3_3.C index ef4fb7276..75022d75d 100644 --- a/src/dyninst/test3_3.C +++ b/src/dyninst/test3_3.C @@ -48,13 +48,13 @@ #include "dyninst_comp.h" class test3_3_Mutator : public DyninstMutator { - unsigned int Mutatees; - int debugPrint; - char *pathname; - BPatch *bpatch; + unsigned int Mutatees{3}; + int debugPrint{}; + char *pathname{}; + BPatch *bpatch{}; public: - test3_3_Mutator(); + test3_3_Mutator() = default; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); @@ -63,10 +63,6 @@ extern "C" DLLEXPORT TestMutator *test3_3_factory() { return new test3_3_Mutator(); } -test3_3_Mutator::test3_3_Mutator() - : Mutatees(3), pathname(NULL), bpatch(NULL) { -} - // // read the result code written to the file test3.out. and return it // diff --git a/src/dyninst/test3_6.C b/src/dyninst/test3_6.C index 64e3261a1..ae36bb92c 100644 --- a/src/dyninst/test3_6.C +++ b/src/dyninst/test3_6.C @@ -52,12 +52,12 @@ #include "dyninst_comp.h" class test3_6_Mutator : public DyninstMutator { - BPatch_exitType expectedSignal; - unsigned int Mutatees; - std::vector pids; - int debugPrint; - BPatch *bpatch; - char *pathname; + BPatch_exitType expectedSignal{}; + unsigned int Mutatees{3}; + std::vector pids{}; + int debugPrint{}; + BPatch *bpatch{}; + char *pathname{}; public: test3_6_Mutator(); @@ -71,8 +71,7 @@ extern "C" DLLEXPORT TestMutator *test3_6_factory() { return new test3_6_Mutator(); } -test3_6_Mutator::test3_6_Mutator() - : Mutatees(3), bpatch(NULL), pathname(NULL) { +test3_6_Mutator::test3_6_Mutator() { #if defined(os_windows_test) expectedSignal = ExitedNormally; #else @@ -88,9 +87,7 @@ test3_6_Mutator::test3_6_Mutator() #if !defined (os_windows_test) static int forkNewMutatee(const char *filename, const char *child_argv[]) { - int pid; - static int pgid = 0; - pid = fork(); + int pid = fork(); if (pid == 0) { // child, do exec dprintf("%s[%d]: before exec in new mutatee %s, pid = %d\n", __FILE__, __LINE__, filename, getpid()); @@ -190,7 +187,6 @@ test_results_t test3_6_Mutator::executeTest() { dprintf("Terminated mutatee [%d] from signal 0x%x\n", n, signalNum); } for (n=0; nregisterOneTimeCodeCallback(test7_oneTimeCodeCallback); + bpatch->registerOneTimeCodeCallback(test7_oneTimeCodeCallback); dprintf("Letting mutatee processes run a short while (2s).\n"); for (n=0; ncontinueExecution(); diff --git a/src/dyninst/test4_1.C b/src/dyninst/test4_1.C index ed16da969..ce4bbf801 100644 --- a/src/dyninst/test4_1.C +++ b/src/dyninst/test4_1.C @@ -47,12 +47,12 @@ #include "dyninst_comp.h" class test4_1_Mutator : public DyninstMutator { - int debugPrint; - BPatch *bpatch; - char *pathname; + int debugPrint{}; + BPatch *bpatch{}; + char *pathname{}; public: - test4_1_Mutator(); + test4_1_Mutator() = default; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); @@ -62,10 +62,6 @@ extern "C" DLLEXPORT TestMutator *test4_1_factory() { return new test4_1_Mutator(); } -test4_1_Mutator::test4_1_Mutator() - : bpatch(NULL), pathname(NULL) { -} - static bool passedTest = false; static BPatch_process *myprocs[25]; static int threadCount = 0; @@ -122,7 +118,7 @@ static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) } else assert(false); } -static void execFunc(BPatch_thread *thread) +static void execFunc(BPatch_thread *) { logerror("**Failed Test #1\n"); logerror(" execCallback invoked, but exec was not called!\n"); diff --git a/src/dyninst/test4_2.C b/src/dyninst/test4_2.C index b8a0c86b7..51a410142 100644 --- a/src/dyninst/test4_2.C +++ b/src/dyninst/test4_2.C @@ -46,13 +46,12 @@ #include "dyninst_comp.h" class test4_2_Mutator : public DyninstMutator { - const unsigned int MAX_TEST; - int debugPrint; - BPatch *bpatch; - char *pathname; + int debugPrint{}; + BPatch *bpatch{}; + char *pathname{}; public: - test4_2_Mutator(); + test4_2_Mutator() = default; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); @@ -62,16 +61,13 @@ extern "C" DLLEXPORT TestMutator *test4_2_factory() { return new test4_2_Mutator(); } -test4_2_Mutator::test4_2_Mutator() - : MAX_TEST(4), bpatch(NULL), pathname(NULL) { -} - static bool passedTest; static int threadCount; static BPatch_process *mythreads[25]; static BPatch_thread *test2Child; static BPatch_thread *test2Parent; static int exited; +constexpr auto MAX_TEST = 4; static void forkFunc(BPatch_thread *parent, BPatch_thread *child) { @@ -204,7 +200,7 @@ static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) } } -static void execFunc(BPatch_thread *thread) +static void execFunc(BPatch_thread *) { logerror("**Failed Test #2\n"); logerror(" execCallback invoked, but exec was not called!\n"); diff --git a/src/dyninst/test4_3.C b/src/dyninst/test4_3.C index ba56a4454..f4d12c17e 100644 --- a/src/dyninst/test4_3.C +++ b/src/dyninst/test4_3.C @@ -46,7 +46,6 @@ #include "dyninst_comp.h" class test4_3_Mutator : public DyninstMutator { - const unsigned int MAX_TEST; BPatch *bpatch; char *pathname; @@ -62,20 +61,20 @@ extern "C" DLLEXPORT TestMutator *test4_3_factory() { } test4_3_Mutator::test4_3_Mutator() - : MAX_TEST(4), bpatch(NULL), pathname(NULL) { + : bpatch(NULL), pathname(NULL) { } static bool passedTest = false; static int threadCount = 0; static BPatch_process *mythreads[25]; static int debugPrint_; +constexpr auto MAX_TEST = 4; static void forkFunc(BPatch_thread *parent, BPatch_thread *child) { // I think this test should set failure in the fork callback. The test4_3 // mutatee doesn't call fork.. dprintf("forkFunc called with parent %p, child %p\n", parent, child); - BPatch_image *appImage; BPatch_Vector bpfv; BPatch_Vector nullArgs; diff --git a/src/dyninst/test4_4.C b/src/dyninst/test4_4.C index 1ac953fb9..cef354955 100644 --- a/src/dyninst/test4_4.C +++ b/src/dyninst/test4_4.C @@ -46,13 +46,12 @@ #include "dyninst_comp.h" class test4_4_Mutator : public DyninstMutator { - const unsigned int MAX_TEST; - BPatch *bpatch; - char *pathname; - int debugPrint; + BPatch *bpatch{}; + char *pathname{}; + int debugPrint{}; public: - test4_4_Mutator(); + test4_4_Mutator() = default; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); @@ -62,16 +61,13 @@ extern "C" DLLEXPORT TestMutator *test4_4_factory() { return new test4_4_Mutator(); } -test4_4_Mutator::test4_4_Mutator() - : MAX_TEST(4), bpatch(NULL), pathname(NULL), debugPrint(0) { -} - static bool passedTest; static int threadCount; static BPatch_process *mythreads[25]; static BPatch_thread *test4Child; static BPatch_thread *test4Parent; +constexpr auto MAX_TEST = 4; static void forkFunc(BPatch_thread *parent, BPatch_thread *child) { diff --git a/src/dyninst/test5_7.C b/src/dyninst/test5_7.C index 5cd33ebc8..714430035 100644 --- a/src/dyninst/test5_7.C +++ b/src/dyninst/test5_7.C @@ -74,8 +74,8 @@ test_results_t test5_7_Mutator::executeTest() { int flag = 0; BPatch_function *func; int bound = point7_1->size(); - BPatch_variableExpr *content7_1; - BPatch_variableExpr *content7_2; + BPatch_variableExpr *content7_1{}; + BPatch_variableExpr *content7_2{}; while (index < bound) { if ((func = (*point7_1)[index]->getCalledFunction()) == NULL) { diff --git a/src/dyninst/test5_8.C b/src/dyninst/test5_8.C index 9245758fd..40f849348 100644 --- a/src/dyninst/test5_8.C +++ b/src/dyninst/test5_8.C @@ -137,8 +137,7 @@ test_results_t test5_8_Mutator::executeTest() { strcpy(fieldName, (*fields)[index]->getName()); if ( !strcmp("CPP_TEST_UTIL_VAR", (*fields)[index]->getName()) ) { dprintf("Inserted snippet2\n"); - BPatchSnippetHandle *handle; - handle = appAddrSpace->insertSnippet(call8Expr, *point8_1); + appAddrSpace->insertSnippet(call8Expr, *point8_1); return PASSED; } diff --git a/src/dyninst/test5_9.C b/src/dyninst/test5_9.C index c774ee7fc..f9b3ab36e 100644 --- a/src/dyninst/test5_9.C +++ b/src/dyninst/test5_9.C @@ -104,7 +104,7 @@ test_results_t test5_9_Mutator::executeTest() { return FAILED; } - int index = 0; + size_t index = 0; while ( index < fields->size() ) { if ( !strcmp("call_cpp", (*fields)[index]->getName()) || !strcmp("cpp_test_util::call_cpp", (*fields)[index]->getName())) { diff --git a/src/dyninst/test_callback_1.C b/src/dyninst/test_callback_1.C index a5959b1a2..d8191bdfe 100644 --- a/src/dyninst/test_callback_1.C +++ b/src/dyninst/test_callback_1.C @@ -70,7 +70,6 @@ static int mutateeXLC = 0; static BPatch_Vector test2handles; static BPatch_Vector dyncalls; static BPatch_process *globalThread = NULL; -extern BPatch *bpatch; static int counter = 0; static int counter2 = 0; diff --git a/src/dyninst/test_callback_2.C b/src/dyninst/test_callback_2.C index 836076888..1df0a5a56 100644 --- a/src/dyninst/test_callback_2.C +++ b/src/dyninst/test_callback_2.C @@ -79,7 +79,7 @@ int callback_counter = 0; std::vector elog; static BPatch_point *findPoint(BPatch_function *f, BPatch_procedureLocation loc, - int testno, const char *testname) + int, const char *) { if(!f) { logerror("%s[%d]: Invaild BPatch_function\n", FILE__, __LINE__); @@ -108,7 +108,7 @@ static BPatch_point *findPoint(BPatch_function *f, BPatch_procedureLocation loc, // -- modify to take snippet vector args if necessary. BPatchSnippetHandle * test_callback_2_Mutator::at(BPatch_point * pt, BPatch_function *call, - int testno, const char *testname) + int, const char *) { BPatch_Vector args; BPatch_funcCallExpr snip(*call, args); @@ -188,7 +188,7 @@ static void test7cb(BPatch_process * proc, void *buf, unsigned int bufsize) elog.push_back(*msg); - if (proc->getPid() != tid) + if (static_cast(proc->getPid()) != tid) { fprintf(stderr, "%s[%d]: ERROR: got event for pid %lu, not %d\n", FILE__, __LINE__, tid, proc->getPid()); } diff --git a/src/dyninst/test_fork_10.C b/src/dyninst/test_fork_10.C index 737856453..6ec12a9f6 100644 --- a/src/dyninst/test_fork_10.C +++ b/src/dyninst/test_fork_10.C @@ -153,7 +153,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_11.C b/src/dyninst/test_fork_11.C index 1bba8b1cc..86d60047e 100644 --- a/src/dyninst/test_fork_11.C +++ b/src/dyninst/test_fork_11.C @@ -179,7 +179,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_12.C b/src/dyninst/test_fork_12.C index de42026dd..9786288c2 100644 --- a/src/dyninst/test_fork_12.C +++ b/src/dyninst/test_fork_12.C @@ -150,7 +150,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_13.C b/src/dyninst/test_fork_13.C index 36cede199..2a49afc17 100644 --- a/src/dyninst/test_fork_13.C +++ b/src/dyninst/test_fork_13.C @@ -158,7 +158,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_14.C b/src/dyninst/test_fork_14.C index 70e257b0a..116679872 100644 --- a/src/dyninst/test_fork_14.C +++ b/src/dyninst/test_fork_14.C @@ -130,7 +130,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_5.C b/src/dyninst/test_fork_5.C index c581129b9..742cb7e3a 100644 --- a/src/dyninst/test_fork_5.C +++ b/src/dyninst/test_fork_5.C @@ -148,7 +148,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_6.C b/src/dyninst/test_fork_6.C index 68d702b6b..70e7d7e00 100644 --- a/src/dyninst/test_fork_6.C +++ b/src/dyninst/test_fork_6.C @@ -78,7 +78,6 @@ static int msgid; static void prepareTestCase2(procType proc_type, BPatch_thread *thread, forkWhen when) { - static BPatchSnippetHandle *parSnippetHandle2; if(proc_type == Parent_p && when == PreFork) { BPatch_image *parImage = thread->getProcess()->getImage(); @@ -109,8 +108,7 @@ static void prepareTestCase2(procType proc_type, BPatch_thread *thread, forkWhen BPatch_arithExpr expr7_2p(BPatch_assign, *var7_2p,BPatch_constExpr(951)); - parSnippetHandle2 = - thread->getProcess()->insertSnippet(expr7_2p, *point7_2p, BPatch_callBefore); + thread->getProcess()->insertSnippet(expr7_2p, *point7_2p, BPatch_callBefore); } else if(proc_type == Child_p && when == PostFork) { BPatch_image *childImage = thread->getProcess()->getImage(); @@ -175,7 +173,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_7.C b/src/dyninst/test_fork_7.C index a45a084ce..ab852d1b1 100644 --- a/src/dyninst/test_fork_7.C +++ b/src/dyninst/test_fork_7.C @@ -184,7 +184,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_8.C b/src/dyninst/test_fork_8.C index 3d3f47f99..efae140d1 100644 --- a/src/dyninst/test_fork_8.C +++ b/src/dyninst/test_fork_8.C @@ -80,7 +80,6 @@ static int msgid; static void prepareTestCase4(procType proc_type, BPatch_thread *thread, forkWhen when) { - static BPatchSnippetHandle *parSnippetHandle4; if(proc_type == Child_p && when == PostFork) { BPatch_image *childImage = thread->getProcess()->getImage(); @@ -110,8 +109,7 @@ static void prepareTestCase4(procType proc_type, BPatch_thread *thread, forkWhen BPatch_arithExpr a_expr7_4c(BPatch_plus, *var7_4c,BPatch_constExpr(211)); BPatch_arithExpr b_expr7_4c(BPatch_assign, *var7_4c, a_expr7_4c); - parSnippetHandle4 = - thread->getProcess()->insertSnippet(b_expr7_4c, *point7_4c, BPatch_callBefore); + thread->getProcess()->insertSnippet(b_expr7_4c, *point7_4c, BPatch_callBefore); } } @@ -142,7 +140,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_fork_9.C b/src/dyninst/test_fork_9.C index a1d299c45..50325f840 100644 --- a/src/dyninst/test_fork_9.C +++ b/src/dyninst/test_fork_9.C @@ -81,7 +81,6 @@ static int msgid; static void prepareTestCase5(procType proc_type, BPatch_thread *thread, forkWhen when) { - static BPatchSnippetHandle *parSnippetHandle5; logerror("prepareTestCase5, %d, %p, %d\n", proc_type, thread, when); @@ -115,8 +114,7 @@ static void prepareTestCase5(procType proc_type, BPatch_thread *thread, forkWhen BPatch_arithExpr expr7_5p(BPatch_plus, *var7_5p, BPatch_constExpr(9)); BPatch_arithExpr b_expr7_5p(BPatch_assign, *var7_5p, expr7_5p); - parSnippetHandle5 = - thread->getProcess()->insertSnippet(b_expr7_5p, *point7_5p, BPatch_callBefore); + thread->getProcess()->insertSnippet(b_expr7_5p, *point7_5p, BPatch_callBefore); } else if(proc_type == Parent_p && when == PostFork) { BPatch_image *parImage = thread->getProcess()->getImage(); @@ -146,14 +144,12 @@ static void prepareTestCase5(procType proc_type, BPatch_thread *thread, forkWhen BPatch_arithExpr a_expr7_5p(BPatch_plus, *var7_5p, BPatch_constExpr(11)); BPatch_arithExpr b_expr7_5p(BPatch_assign, *var7_5p, a_expr7_5p); - parSnippetHandle5 = - thread->getProcess()->insertSnippet(b_expr7_5p, *point7_5p, BPatch_callBefore, + thread->getProcess()->insertSnippet(b_expr7_5p, *point7_5p, BPatch_callBefore, BPatch_lastSnippet); BPatch_arithExpr c_expr7_5p(BPatch_plus, *var7_5p, BPatch_constExpr(13)); BPatch_arithExpr d_expr7_5p(BPatch_assign, *var7_5p, c_expr7_5p); - parSnippetHandle5 = - thread->getProcess()->insertSnippet(d_expr7_5p, *point7_5p, BPatch_callBefore); + thread->getProcess()->insertSnippet(d_expr7_5p, *point7_5p, BPatch_callBefore); } else if(proc_type == Child_p && when == PostFork) { BPatch_image *childImage = thread->getProcess()->getImage(); @@ -183,13 +179,11 @@ static void prepareTestCase5(procType proc_type, BPatch_thread *thread, forkWhen BPatch_arithExpr a_expr7_5c(BPatch_plus, *var7_5c, BPatch_constExpr(5)); BPatch_arithExpr b_expr7_5c(BPatch_assign, *var7_5c, a_expr7_5c); - parSnippetHandle5 = - thread->getProcess()->insertSnippet(b_expr7_5c, *point7_5c, BPatch_callBefore, + thread->getProcess()->insertSnippet(b_expr7_5c, *point7_5c, BPatch_callBefore, BPatch_lastSnippet); BPatch_arithExpr c_expr7_5c(BPatch_plus, *var7_5c, BPatch_constExpr(3)); BPatch_arithExpr d_expr7_5c(BPatch_assign, *var7_5c, c_expr7_5c); - parSnippetHandle5 = - thread->getProcess()->insertSnippet(d_expr7_5c, *point7_5c, BPatch_callBefore); + thread->getProcess()->insertSnippet(d_expr7_5c, *point7_5c, BPatch_callBefore); } } @@ -221,7 +215,7 @@ static void postForkFunc(BPatch_thread *parent, BPatch_thread *child) } /* And verify them when they exit */ -static void exitFunc(BPatch_thread *thread, BPatch_exitType exit_type) { +static void exitFunc(BPatch_thread *thread, BPatch_exitType) { dprintf("Exit func called\n"); if (thread == parentThread) { dprintf("Parent exit reached, checking...\n"); diff --git a/src/dyninst/test_lib_mutateeStart.C b/src/dyninst/test_lib_mutateeStart.C index 769361916..36e73fdab 100644 --- a/src/dyninst/test_lib_mutateeStart.C +++ b/src/dyninst/test_lib_mutateeStart.C @@ -62,7 +62,7 @@ static void clearBinEditFiles() } int num_files = result; - for (unsigned i=0; id_name, ".") == 0) || (strcmp(files[i]->d_name, "..") == 0)) { diff --git a/src/dyninst/test_lib_test9.C b/src/dyninst/test_lib_test9.C index ee13f6c36..06bf5f1c8 100644 --- a/src/dyninst/test_lib_test9.C +++ b/src/dyninst/test_lib_test9.C @@ -34,9 +34,6 @@ #include #include -extern FILE *outlog; -extern FILE *errlog; - #if !defined(os_windows_test) #include #include diff --git a/src/dyninst/test_pt_ls.C b/src/dyninst/test_pt_ls.C index 7f2b81530..fb87311e5 100644 --- a/src/dyninst/test_pt_ls.C +++ b/src/dyninst/test_pt_ls.C @@ -102,7 +102,7 @@ test_results_t test_pt_ls_Mutator::executeTest() std::vector args; args.push_back(std::string("/")); - test_results_t res; + test_results_t res{UNKNOWN}; if (runmode == CREATE) { res = parseThat(cmd, args); } else if (runmode == DISK) { @@ -135,7 +135,7 @@ test_results_t test_pt_ls_Mutator::executeTest() // We only need to check the tail end of the output file. fseek(fp, 0, SEEK_END); if (fseek(fp, -(sizeof(buf)-1), SEEK_CUR) != 0) rewind(fp); - if(fread(buf, sizeof(char), sizeof(buf)-1, fp) == EOF) { + if(fread(buf, sizeof(char), sizeof(buf)-1, fp) == 0UL && feof(fp) != 0) { perror("Read failed"); } diff --git a/src/dyninst/test_reloc.C b/src/dyninst/test_reloc.C index 14f6389e4..530ce5a2a 100644 --- a/src/dyninst/test_reloc.C +++ b/src/dyninst/test_reloc.C @@ -61,7 +61,6 @@ extern "C" DLLEXPORT TestMutator* test_reloc_factory() // Start Test Case test_reloc // test_results_t test_reloc_Mutator::executeTest() { - const char *testname = "Relocate all functions in binary without any instrumentation"; //Get all procedures from binary (only binary procuderes, not the ones in linked libraries too) diff --git a/src/dyninst/test_thread_1.C b/src/dyninst/test_thread_1.C index 25c1977d8..8c78772d3 100644 --- a/src/dyninst/test_thread_1.C +++ b/src/dyninst/test_thread_1.C @@ -58,14 +58,6 @@ extern "C" DLLEXPORT TestMutator *test_thread_1_factory() { #define TESTNAME "test_thread_1" #define TESTDESC "rtlib spinlocks" -static int mutateeXLC; - -static const char *expected_fnames[] = {"call1_1","call1_2","call1_3","call1_4"}; -static int test1done = 0; -static int test1err = 0; -static BPatch_Vector test1handles; -static BPatch_Vector dyncalls; - // static int mutatorTest(BPatch_thread *appT, BPatch_image *appImage) test_results_t test_thread_1_Mutator::executeTest() { // Just continue the process and wait for the (mutatee side) test to complete diff --git a/src/dyninst/test_thread_6.C b/src/dyninst/test_thread_6.C index 62e70c503..affa5e8bf 100644 --- a/src/dyninst/test_thread_6.C +++ b/src/dyninst/test_thread_6.C @@ -101,7 +101,7 @@ template void clear(Container &c, std::mutex &m) { c.clear(); } template -bool has_value(Container const &c, std::mutex &m, Value v) { +bool has_value(Container const &, std::mutex &m, Value v) { std::lock_guard l{m}; for (auto const &p : tids) { if (p.second == v) { @@ -272,7 +272,7 @@ static bool wait_thread_termination() { return true; } -test_results_t test_thread_6_Mutator::mutatorTest(BPatch *bpatch) { +test_results_t test_thread_6_Mutator::mutatorTest(BPatch *) { this->appProc->continueExecution(); // Register callbacks for threads in this process diff --git a/src/dyninst/test_thread_7.C b/src/dyninst/test_thread_7.C index e37a1e11c..15ddc33e3 100644 --- a/src/dyninst/test_thread_7.C +++ b/src/dyninst/test_thread_7.C @@ -45,18 +45,18 @@ class test_thread_7_Mutator : public DyninstMutator { protected: - BPatch *bpatch; - bool create_proc; - char *filename; - BPatch_process *proc; - const char *args[MAX_ARGS]; - unsigned num_args; + BPatch *bpatch{}; + bool create_proc{true}; + char *filename{}; + BPatch_process *proc{}; + const char *args[MAX_ARGS]{}; + unsigned num_args{}; BPatch_process *getProcess(); void instr_func(BPatch_function *func, BPatch_function *lvl1func); public: - test_thread_7_Mutator(); + test_thread_7_Mutator() = default; virtual bool hasCustomExecutionPath() { return true; } virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t executeTest(); @@ -65,15 +65,10 @@ extern "C" DLLEXPORT TestMutator *test_thread_7_factory() { return new test_thread_7_Mutator(); } -test_thread_7_Mutator::test_thread_7_Mutator() - : bpatch(NULL), create_proc(true), filename(NULL), num_args(0) { -} - // static FILE *outlog = NULL; // static FILE *errlog = NULL; -static bool debug_flag = true; #define dprintf if (debug_flag) fprintf void test_thread_7_Mutator::instr_func(BPatch_function *func, diff --git a/src/instruction/aarch64_cft.C b/src/instruction/aarch64_cft.C index 890c2f654..b1e42eb26 100644 --- a/src/instruction/aarch64_cft.C +++ b/src/instruction/aarch64_cft.C @@ -193,7 +193,7 @@ test_results_t aarch64_cft_Mutator::executeTest() { continue; } - const auto num_cft = std::distance(insn.cft_begin(), insn.cft_end()); + const size_t num_cft = std::distance(insn.cft_begin(), insn.cft_end()); const auto num_expected_cft = t.expected_targets.size(); if(num_cft != num_expected_cft) { diff --git a/src/instruction/instruction_comp.C b/src/instruction/instruction_comp.C index b3c693a97..c32b4a559 100644 --- a/src/instruction/instruction_comp.C +++ b/src/instruction/instruction_comp.C @@ -68,37 +68,37 @@ InstructionComponent::~InstructionComponent() { } -test_results_t InstructionComponent::program_setup(ParameterDict ¶ms) +test_results_t InstructionComponent::program_setup(ParameterDict &) { return PASSED; } -test_results_t InstructionComponent::program_teardown(ParameterDict ¶ms) +test_results_t InstructionComponent::program_teardown(ParameterDict &) { return PASSED; } -test_results_t InstructionComponent::group_setup(RunGroup *group, ParameterDict ¶ms) +test_results_t InstructionComponent::group_setup(RunGroup *, ParameterDict &) { return PASSED; } -test_results_t InstructionComponent::group_teardown(RunGroup *group, ParameterDict ¶ms) +test_results_t InstructionComponent::group_teardown(RunGroup *, ParameterDict &) { return PASSED; } -test_results_t InstructionComponent::test_setup(TestInfo *test, ParameterDict ¶ms) +test_results_t InstructionComponent::test_setup(TestInfo *, ParameterDict &) { return PASSED; } -test_results_t InstructionComponent::test_teardown(TestInfo *test, ParameterDict ¶ms) +test_results_t InstructionComponent::test_teardown(TestInfo *, ParameterDict &) { return PASSED; } -test_results_t InstructionMutator::setup(ParameterDict ¶m) +test_results_t InstructionMutator::setup(ParameterDict &) { return PASSED; } diff --git a/src/instruction/power_cft.C b/src/instruction/power_cft.C index 1916aff8f..c84bc26cc 100644 --- a/src/instruction/power_cft.C +++ b/src/instruction/power_cft.C @@ -255,17 +255,21 @@ namespace { */ { // b +16 0x48000010, is_branch, !is_return, - test_cft{pc_value + 16, {!is_call, !is_conditional, !is_indirect, !is_fallthrough}} + test_cft{pc_value + 16, {!is_call, !is_conditional, !is_indirect, !is_fallthrough}}, + {}, {}, {}, {} }, { // ba -48 - 0x4bffffd2, is_branch, !is_return + 0x4bffffd2, is_branch, !is_return, + {}, {}, {}, {}, {} }, { // bl 0x100 0x48000101, !is_branch, !is_return, - test_cft{pc_value + 0x100, {is_call, !is_conditional, !is_indirect, !is_fallthrough}} + test_cft{pc_value + 0x100, {is_call, !is_conditional, !is_indirect, !is_fallthrough}}, + {}, {}, {}, {} }, { // bla 0x100 - 0x48000103, !is_branch, !is_return + 0x48000103, !is_branch, !is_return, + {}, {}, {}, {}, {} }, /* @@ -314,6 +318,8 @@ namespace { {}, {}, test_cft{lr_value, {!is_call, !is_conditional, is_indirect, !is_fallthrough}}, + {}, + {} }, { // bclrl (LK=1) 0x4e800021, is_branch, !is_return, @@ -344,6 +350,8 @@ namespace { {}, {}, test_cft{lr_value, {!is_call, !is_conditional, is_indirect, !is_fallthrough}}, + {}, + {} }, /* @@ -353,16 +361,19 @@ namespace { 0x4e800420, is_branch, !is_return, {}, test_cft{ctr_value, {!is_call, !is_conditional, is_indirect, !is_fallthrough}}, + {}, {}, {} }, { // bctrl (LK=1) 0x4e800421, !is_branch, !is_return, {}, test_cft{ctr_value, {is_call, !is_conditional, is_indirect, !is_fallthrough}}, + {}, {}, {} }, { // bcctr 0x17, 4*cr4+lt, 0 0x4ef00420, is_branch, !is_return, {}, - test_cft{ctr_value, {!is_call, !is_conditional, is_indirect, !is_fallthrough}} + test_cft{ctr_value, {!is_call, !is_conditional, is_indirect, !is_fallthrough}}, + {}, {}, {} }, /* diff --git a/src/instruction/test_instruction_profile.C b/src/instruction/test_instruction_profile.C index 350bdd231..7f052e30a 100644 --- a/src/instruction/test_instruction_profile.C +++ b/src/instruction/test_instruction_profile.C @@ -111,7 +111,7 @@ test_results_t test_instruction_profile_Mutator::executeTest() return SKIPPED; #endif - long offset = 0; + uint64_t offset = 0; // simulate parsing via vector-per-basic-block while(offset < (*curReg)->getDiskSize() - InstructionDecoder::maxInstructionLength) diff --git a/src/mutatee_util.c b/src/mutatee_util.c index 086b885b5..b262650ce 100644 --- a/src/mutatee_util.c +++ b/src/mutatee_util.c @@ -57,7 +57,6 @@ extern "C" { #include "mutatee_call_info.h" extern mutatee_call_info_t mutatee_funcs[]; extern int passedTest[]; - extern unsigned int MAX_TEST; #include "test_results.h" diff --git a/src/proccontrol/pc_addlibrary.C b/src/proccontrol/pc_addlibrary.C index ab7bbd1fb..2ca4bfd5f 100644 --- a/src/proccontrol/pc_addlibrary.C +++ b/src/proccontrol/pc_addlibrary.C @@ -45,14 +45,14 @@ extern "C" DLLEXPORT TestMutator* pc_addlibrary_factory() static std::set lib_success; static bool had_error; -static Process::cb_ret_t on_breakpoint(Event::const_ptr ev) +static Process::cb_ret_t on_breakpoint(Event::const_ptr) { logerror("Should not have received breakpoint callback\n"); had_error = true; return Process::cbDefault; } -static Process::cb_ret_t on_irpc(Event::const_ptr ev) +static Process::cb_ret_t on_irpc(Event::const_ptr) { logerror("Should not have received irpc callback\n"); had_error = true; diff --git a/src/proccontrol/pc_breakpoint.C b/src/proccontrol/pc_breakpoint.C index 5d1b717d7..34caacd9d 100644 --- a/src/proccontrol/pc_breakpoint.C +++ b/src/proccontrol/pc_breakpoint.C @@ -52,14 +52,14 @@ extern "C" DLLEXPORT TestMutator* pc_breakpoint_factory() #define NUM_BREAKPOINTS 4 #define NUM_BREAKPOINT_SPINS 16 -Dyninst::Address bp_addrs[NUM_PARALLEL_PROCS][NUM_BREAKPOINTS]; -Breakpoint::ptr bps[NUM_PARALLEL_PROCS][NUM_BREAKPOINTS]; -std::pair indexes[NUM_PARALLEL_PROCS*NUM_BREAKPOINTS]; -unsigned cur_index; -std::map hit_counts; -unsigned num_breakpoints_hit; +Dyninst::Address bp_addrs[NUM_PARALLEL_PROCS][NUM_BREAKPOINTS]{}; +Breakpoint::ptr bps[NUM_PARALLEL_PROCS][NUM_BREAKPOINTS]{}; +std::pair indexes[NUM_PARALLEL_PROCS*NUM_BREAKPOINTS]{}; +unsigned cur_index{}; +std::map hit_counts{}; +int num_breakpoints_hit{}; bool haserror = false; -unsigned my_num_processes; +unsigned my_num_processes{}; Process::cb_ret_t on_breakpoint(Event::const_ptr ev) { @@ -129,8 +129,6 @@ test_results_t pc_breakpointMutator::executeTest() cur_index = 0; num_breakpoints_hit = 0; hit_counts.clear(); - memset(indexes, 0, sizeof(indexes)); - memset(bp_addrs, 0, sizeof(bp_addrs)); my_num_processes = comp->num_processes; for (unsigned i=0; i(pi.parent.get())); + fprintf(stderr, "proc = %p\n", reinterpret_cast(proc.get())); + fprintf(stderr, "pi.child = %p\n", reinterpret_cast(pi.child.get())); fprintf(stderr, "pi.parent = %d\n", pi.parent->getPid()); fprintf(stderr, "proc = %d\n", proc->getPid()); fprintf(stderr, "pi.child = %d\n", pi.child->getPid()); @@ -227,7 +227,7 @@ test_results_t pc_forkMutator::executeTest() myerror = true; continue; } - if (pi.child->getPid() != fork_data.pid) { + if (static_cast(pi.child->getPid()) != fork_data.pid) { logerror("Unexpected pid\n"); myerror = true; continue; diff --git a/src/proccontrol/pc_fork_exec.C b/src/proccontrol/pc_fork_exec.C index a58b55c39..dc80ab954 100644 --- a/src/proccontrol/pc_fork_exec.C +++ b/src/proccontrol/pc_fork_exec.C @@ -59,7 +59,7 @@ static bool myerror; const char *exec_name = "pc_exec_targ"; const char *libtestA = "libtestA"; -static bool hasLibrary(std::string lib, Process::const_ptr proc) +static bool hasLibrary(std::string, Process::const_ptr proc) { LibraryPool::const_iterator i = proc->libraries().begin(); for (; i != proc->libraries().end(); i++) { @@ -103,8 +103,6 @@ Process::cb_ret_t on_fork(Event::const_ptr ev) return Process::cbDefault; } - proc_info_forkexec &pi = pinfo[child_proc]; - if (child_proc->libraries().size() != parent_proc->libraries().size()) { logerror("Parent and child procs do not have same libraries\n"); @@ -173,7 +171,7 @@ test_results_t pc_fork_execMutator::executeTest() } } - if (pinfo.size() != comp->num_processes * (comp->num_threads+1)) { + if (pinfo.size() != static_cast(comp->num_processes * (comp->num_threads+1))) { logerror("Did not recieve expected number of callbacks\n"); myerror = true; } diff --git a/src/proccontrol/pc_groups.C b/src/proccontrol/pc_groups.C index cd28b0be2..6e32eaa72 100644 --- a/src/proccontrol/pc_groups.C +++ b/src/proccontrol/pc_groups.C @@ -62,7 +62,7 @@ extern "C" DLLEXPORT TestMutator* pc_groups_factory() return new pc_groupsMutator(); } -Process::cb_ret_t on_bp(Event::const_ptr ev) { +Process::cb_ret_t on_bp(Event::const_ptr) { num_bp_events++; return Process::cbProcContinue; } @@ -79,7 +79,7 @@ void pc_groupsMutator::waitfor_sync() { error = true; } - for (unsigned int i = 0; i < comp->num_processes; i++) { + for (int i = 0; i < comp->num_processes; i++) { if (syncs[i].code != SYNCLOC_CODE) { logerror("Received bad syncloc message in group test\n"); error = true; diff --git a/src/proccontrol/pc_irpc.C b/src/proccontrol/pc_irpc.C index 398d0e4c9..ac13b404f 100644 --- a/src/proccontrol/pc_irpc.C +++ b/src/proccontrol/pc_irpc.C @@ -73,12 +73,12 @@ struct rpc_data_t { }; struct proc_info_t { - Dyninst::Address val; - Dyninst::Address irpc_calltarg; - Dyninst::Address irpc_tocval; - Dyninst::Address busywait; - std::vector rpcs; - proc_info_t() : val(0), irpc_calltarg(0) {} + Dyninst::Address val{}; + Dyninst::Address irpc_calltarg{}; + Dyninst::Address irpc_tocval{}; + Dyninst::Address busywait{}; + std::vector rpcs{}; + proc_info_t() = default; void clear() { for (unsigned i=0; ithreads().end(); j++) { Thread::ptr thr = *j; - thread_info_t &t = tinfo[thr]; if(!thr->isUser()) { continue; @@ -382,14 +381,13 @@ void pc_irpcMutator::runIRPCs() { { Thread::const_ptr thr = i->first; Process::const_ptr proc = thr->getProcess(); - thread_info_t &t = i->second; if(!thr->isUser()) { continue; } int num_to_post_now = (post_time == post_all_once) ? NUM_IRPCS : 1; - for (unsigned j=0; jnum_threads+1) * NUM_IRPCS) { + if (val != static_cast((comp->num_threads+1) * NUM_IRPCS)) { logerror("val = %d, expected = %d\n", val, (comp->num_threads+1)*NUM_IRPCS); logerror("IRPCS did not update val\n"); myerror = true; @@ -585,7 +581,7 @@ Process::cb_ret_t on_irpc(Event::const_ptr ev) int &cur = t.cur; - assert(cur < t.rpcs.size()); + assert(static_cast(cur) < t.rpcs.size()); if (t.rpcs[cur] != rpcdata) { if (post_to != post_to_proc) { diff --git a/src/proccontrol/pc_irpc_asm.h b/src/proccontrol/pc_irpc_asm.h index d237887de..71b9aa774 100644 --- a/src/proccontrol/pc_irpc_asm.h +++ b/src/proccontrol/pc_irpc_asm.h @@ -30,7 +30,7 @@ static void createBuffer(Process::ptr proc, Dyninst::Address calltarg, - Dyninst::Address tocval, + Dyninst::Address, unsigned char* &buffer, unsigned &buffer_size, unsigned long &start_offset) { diff --git a/src/proccontrol/pc_library.C b/src/proccontrol/pc_library.C index f77703c73..0db26492d 100644 --- a/src/proccontrol/pc_library.C +++ b/src/proccontrol/pc_library.C @@ -79,7 +79,7 @@ static std::map proclibs; static bool got_breakpoint; static bool myerror; -Process::cb_ret_t on_breakpoint(Event::const_ptr ev) +Process::cb_ret_t on_breakpoint(Event::const_ptr) { got_breakpoint = true; return Process::cbDefault; diff --git a/src/proccontrol/pc_singlestep.C b/src/proccontrol/pc_singlestep.C index 702ca9188..41b48db67 100644 --- a/src/proccontrol/pc_singlestep.C +++ b/src/proccontrol/pc_singlestep.C @@ -85,7 +85,6 @@ Breakpoint::ptr early_bp; Breakpoint::ptr ss_bp; static bool myerror; -static bool goingToSS = false; Process::cb_ret_t on_breakpoint(Event::const_ptr ev) { @@ -123,8 +122,6 @@ Process::cb_ret_t on_breakpoint(Event::const_ptr ev) return Process::cbProcContinue; } -static int instCount = 0; - Process::cb_ret_t on_singlestep(Event::const_ptr ev) { MachRegister pc = MachRegister::getPC(ev->getProcess()->getArchitecture()); @@ -208,7 +205,6 @@ test_results_t pc_singlestepMutator::executeTest() pi.start = comp->adjustFunctionEntryAddress(proc, addrmsg.addr); logerror("initial breakpoint at 0x%lx\n", addrmsg.addr); - Address funcs[NUM_FUNCS]; for (unsigned j=0; j < NUM_FUNCS; j++) { bool result = comp->recv_message((unsigned char *) &addrmsg, sizeof(send_addr), proc); if (!result) { @@ -315,7 +311,7 @@ test_results_t pc_singlestepMutator::executeTest() logerror("Thread did not receive any single step events\n"); myerror = true; } - for (unsigned j = 0; j < NUM_FUNCS; j++) { + for (int j = 0; j < NUM_FUNCS; j++) { if (j > STOP_FUNC) { if (ti.hit_funcs[j] != -1) { logerror("Stop function was single stepped\n"); diff --git a/src/proccontrol/pc_stat.C b/src/proccontrol/pc_stat.C index 2ed11836f..23074e72d 100644 --- a/src/proccontrol/pc_stat.C +++ b/src/proccontrol/pc_stat.C @@ -92,7 +92,7 @@ void pc_statMutator::waitfor_sync() { error = true; } - for (unsigned int i = 0; i < comp->num_processes; i++) { + for (int i = 0; i < comp->num_processes; i++) { if (syncs[i].code != SYNCLOC_CODE) { logerror("Received bad syncloc message in group test\n"); error = true; @@ -270,12 +270,12 @@ test_results_t pc_statMutator::executeTest() pset = comp->pset; spin_addrs = getAddresses(pset); - if (error || spin_addrs->size() != comp->num_processes) { + if (error || spin_addrs->size() != static_cast(comp->num_processes)) { logerror("Error getting addresses from mutatee\n"); return FAILED; } - for (unsigned i=0; i < 10; i++) { + for (int i=0; i < 10; i++) { waitfor_sync(); if (error) return FAILED; diff --git a/src/proccontrol/pc_temp_detach.C b/src/proccontrol/pc_temp_detach.C index 4bc23d2ea..a3e2c8048 100644 --- a/src/proccontrol/pc_temp_detach.C +++ b/src/proccontrol/pc_temp_detach.C @@ -42,7 +42,7 @@ extern "C" DLLEXPORT TestMutator* pc_temp_detach_factory() static bool event_source_error = false; static bool not_expecting_event = true; -Process::cb_ret_t on_event_source_event(Event::const_ptr ev) +Process::cb_ret_t on_event_source_event(Event::const_ptr) { if( not_expecting_event ) { //We should not see any of the signals if the detach worked diff --git a/src/proccontrol/pc_thread.C b/src/proccontrol/pc_thread.C index 9f35cb6cf..26c441784 100644 --- a/src/proccontrol/pc_thread.C +++ b/src/proccontrol/pc_thread.C @@ -331,7 +331,7 @@ static Process::cb_ret_t lwp_destroy(Event::const_ptr ev) static void checkThreadMsg(threadinfo tinfo, Process::ptr proc) { - if (tinfo.pid != proc->getPid()) { + if (tinfo.pid != static_cast(proc->getPid())) { logerror("Error. Mismatched pids in checkThreadMsg\n", tinfo.pid, proc->getPid()); has_error = true; } @@ -478,11 +478,10 @@ test_results_t pc_threadMutator::executeTest() } } - int num_thrds = comp->num_processes * comp->num_threads; int num_noninit_thrds = comp->num_processes * (comp->num_threads - 1); for (i = comp->procs.begin(); i != comp->procs.end(); i++) { - for (unsigned j=0; j < comp->num_threads+1; j++) { + for (int j=0; j < comp->num_threads+1; j++) { threadinfo tinfo; bool result = comp->recv_message((unsigned char *) &tinfo, sizeof(threadinfo), *i); if (!result) { @@ -505,7 +504,7 @@ test_results_t pc_threadMutator::executeTest() while ((has_thr && user_exit_cb_count < num_noninit_thrds) || (has_lwp && lwp_exit_cb_count < num_noninit_thrds)) { - if (exited_processes.size() >= comp->num_processes) { + if (exited_processes.size() >= static_cast(comp->num_processes)) { logerror("Process exited while waiting for thread termination events.\n"); has_error = true; break; diff --git a/src/proccontrol/pc_thread_cont.C b/src/proccontrol/pc_thread_cont.C index db4941dd5..71fd70f6e 100644 --- a/src/proccontrol/pc_thread_cont.C +++ b/src/proccontrol/pc_thread_cont.C @@ -170,7 +170,7 @@ test_results_t pc_thread_contMutator::executeTest() error = true; } - if( (*i)->threads().size() != comp->num_threads+1 ) { + if( (*i)->threads().size() != static_cast(comp->num_threads+1) ) { logerror("Unexpected size of thread pool\n"); error = true; } @@ -218,7 +218,7 @@ test_results_t pc_thread_contMutator::executeTest() } // Continue a single thread and wait for it to exit - for (unsigned j=0; j < comp->num_threads; j++) { + for (int j=0; j < comp->num_threads; j++) { for (i = comp->procs.begin(); i != comp->procs.end(); i++) { Process::ptr proc = *i; diff --git a/src/proccontrol/proccontrol_comp.C b/src/proccontrol/proccontrol_comp.C index 055c2c2b5..3d1a46c80 100644 --- a/src/proccontrol/proccontrol_comp.C +++ b/src/proccontrol/proccontrol_comp.C @@ -249,32 +249,18 @@ TEST_DLL_EXPORT ComponentTester *componentTesterFactory() return (ComponentTester *) new ProcControlComponent(); } -ProcControlMutator::ProcControlMutator() -{ -} - -ProcControlMutator::~ProcControlMutator() -{ -} - test_results_t ProcControlMutator::setup(ParameterDict ¶m) { comp = (ProcControlComponent *) param["ProcControlComponent"]->getPtr(); return PASSED; } -test_results_t ProcControlMutator::pre_init(ParameterDict ¶m) +test_results_t ProcControlMutator::pre_init(ParameterDict &) { return PASSED; } -ProcControlComponent::ProcControlComponent() : - sockfd(0), - sockname(NULL), - notification_fd(-1), - num_processes(0), - num_threads(0) -{ +ProcControlComponent::ProcControlComponent() { notification_fd = evNotify()->getFD(); #if defined(os_windows_test) WORD wsVer = MAKEWORD(2,2); @@ -321,7 +307,7 @@ bool ProcControlComponent::registerEventCounter(EventType et) return Process::registerEventCallback(et, eventCounterFunction); } -bool ProcControlComponent::checkThread(const Thread &thread) +bool ProcControlComponent::checkThread(const Thread &) { return true; } @@ -397,7 +383,7 @@ ProcessSet::ptr ProcControlComponent::startMutateeSet(RunGroup *group, Parameter if (do_create) { vector cinfo; - for (unsigned i=0; i ainfo; - for (unsigned i=0; i argv; getMutateeParams(group, params, ai.executable, argv); @@ -666,7 +652,7 @@ bool ProcControlComponent::startMutatees(RunGroup *group, ParameterDict ¶m) if (support_lwps && check_threads_on_startup) { - while (eventsRecieved[EventType(EventType::None, EventType::LWPCreate)].size() < num_procs*num_threads) { + while (eventsRecieved[EventType(EventType::None, EventType::LWPCreate)].size() < static_cast(num_procs*num_threads)) { bool result = Process::handleEvents(true); if (!result) { logerror("Failed to handle events during thread create\n"); @@ -678,7 +664,7 @@ bool ProcControlComponent::startMutatees(RunGroup *group, ParameterDict ¶m) if (support_user_threads && check_threads_on_startup) { - while (eventsRecieved[EventType(EventType::None, EventType::UserThreadCreate)].size() < num_procs*num_threads) { + while (eventsRecieved[EventType(EventType::None, EventType::UserThreadCreate)].size() < static_cast(num_procs*num_threads)) { bool result = Process::handleEvents(true); if (!result) { logerror("Failed to handle events during thread create\n"); @@ -692,7 +678,7 @@ bool ProcControlComponent::startMutatees(RunGroup *group, ParameterDict ¶m) { for (std::vector::iterator j = procs.begin(); j != procs.end(); j++) { Process::ptr proc = *j; - if (proc->threads().size() != num_threads+1) { + if (proc->threads().size() != static_cast(num_threads+1)) { logerror("Process has incorrect number of threads"); error = true; } @@ -730,7 +716,7 @@ test_results_t ProcControlComponent::program_setup(ParameterDict ¶ms) return PASSED; } -test_results_t ProcControlComponent::program_teardown(ParameterDict ¶ms) +test_results_t ProcControlComponent::program_teardown(ParameterDict &) { cleanSocket(); @@ -865,12 +851,12 @@ test_results_t ProcControlComponent::group_teardown(RunGroup *group, ParameterDi return error ? FAILED : PASSED; } -test_results_t ProcControlComponent::test_setup(TestInfo *test, ParameterDict &parms) +test_results_t ProcControlComponent::test_setup(TestInfo *, ParameterDict &) { return PASSED; } -test_results_t ProcControlComponent::test_teardown(TestInfo *test, ParameterDict &parms) +test_results_t ProcControlComponent::test_teardown(TestInfo *, ParameterDict &) { return PASSED; } @@ -891,15 +877,16 @@ ProcControlComponent::~ProcControlComponent() void handleError(const char* msg) { - char details[1024]; #if defined(os_windows_test) int err = WSAGetLastError(); - ::FormatMessage(0, NULL, err, 0, details, 1024, NULL); + char buf[1024]; + ::FormatMessage(0, NULL, err, 0, details, 1024, NULL); + std::string details(buf); #else - strncpy(details, strerror(errno), 1024); + std::string details = strerror(errno); #endif - fprintf(stderr, "handleError: %s\n", details); - logerror(msg, details); + fprintf(stderr, "handleError: %s\n", details.c_str()); + logerror(msg, details.c_str()); } bool ProcControlComponent::setupServerSocket(ParameterDict ¶m) @@ -960,7 +947,7 @@ bool ProcControlComponent::acceptConnections(int num, int *attach_sock) vector socks; assert(num == 1 || !attach_sock); //If attach_sock, then num == 1 - while (socks.size() < num) { + while (socks.size() < static_cast(num)) { fd_set readset; FD_ZERO(&readset); fd_set writeset; FD_ZERO(&writeset); fd_set exceptset; FD_ZERO(&exceptset); @@ -1005,7 +992,7 @@ bool ProcControlComponent::acceptConnections(int num, int *attach_sock) } } - for (unsigned i=0; i::iterator i = process_pids.begin(); i != process_pids.end(); i++) { bool result = send_message(msg, msg_size, i->second); if (!result) diff --git a/src/proccontrol/proccontrol_comp.h b/src/proccontrol/proccontrol_comp.h index d2a82d88e..6382f981e 100644 --- a/src/proccontrol/proccontrol_comp.h +++ b/src/proccontrol/proccontrol_comp.h @@ -60,23 +60,23 @@ class COMPLIB_DLL_EXPORT ProcControlComponent : public ComponentTester ProcessSet::ptr startMutateeSet(RunGroup *group, ParameterDict ¶m); bool startMutatees(RunGroup *group, ParameterDict ¶m); public: - int sockfd; - char *sockname; - int notification_fd; - bool check_threads_on_startup; + int sockfd{}; + char *sockname{}; + int notification_fd{-1}; + bool check_threads_on_startup{}; - int num_processes; - int num_threads; + int num_processes{}; + int num_threads{}; - bool curgroup_self_cleaning; + bool curgroup_self_cleaning{}; - std::map process_socks; - std::map process_pids; - std::vector procs; - ProcessSet::ptr pset; - std::map, eventtype_cmp > eventsRecieved; + std::map process_socks{}; + std::map process_pids{}; + std::vector procs{}; + ProcessSet::ptr pset{}; + std::map, eventtype_cmp > eventsRecieved{}; - ParamPtr me; + ParamPtr me{}; #if defined(os_windows_test) HANDLE winsock_event; @@ -118,12 +118,12 @@ class COMPLIB_DLL_EXPORT ProcControlComponent : public ComponentTester // Base class for the mutator part of a test class COMPLIB_DLL_EXPORT ProcControlMutator : public TestMutator { public: - ProcControlMutator(); + ProcControlMutator() = default; virtual test_results_t setup(ParameterDict ¶m); virtual test_results_t pre_init(ParameterDict ¶m); - virtual ~ProcControlMutator(); + virtual ~ProcControlMutator() = default; - ProcControlComponent *comp; + ProcControlComponent *comp{}; }; extern "C" { diff --git a/src/remotetest.C b/src/remotetest.C index 9a81e4a9a..75e00719c 100644 --- a/src/remotetest.C +++ b/src/remotetest.C @@ -170,8 +170,8 @@ static char *decodeGroup(RunGroup* &group, vector &groups, char *buf assert(strcmp(cur, GROUP_ARG) == 0); unsigned int group_index; cur = my_strtok(NULL, ":;"); - sscanf(cur, "%d", &group_index); - assert(group_index >= 0 && group_index < groups.size()); + sscanf(cur, "%u", &group_index); + assert(static_cast(group_index) < groups.size()); group = groups[group_index]; return strchr(buffer, ';')+1; } @@ -190,13 +190,13 @@ static char *decodeTest(TestInfo* &test, vector &groups, char *buffe unsigned int group_index, test_index; cur = my_strtok(NULL, ":;"); - sscanf(cur, "%d", &group_index); - assert(group_index >= 0 && group_index < groups.size()); + sscanf(cur, "%u", &group_index); + assert(static_cast(group_index) < groups.size()); RunGroup *group = groups[group_index]; cur = my_strtok(NULL, ":;"); - sscanf(cur, "%d", &test_index); - assert(test_index >= 0 && test_index < group->tests.size()); + sscanf(cur, "%u", &test_index); + assert(static_cast(test_index) < group->tests.size()); test = group->tests[test_index]; @@ -575,8 +575,8 @@ RemoteTestFE *RemoteTestFE::createRemoteTestFE(TestInfo *t, Connection *c) { } RemoteBE::RemoteBE(vector &g, Connection *c) : - groups(g), - connection(c) + connection(c), + groups(g) { } @@ -688,7 +688,7 @@ void RemoteBE::dispatchComp(char *message) ParameterDict params; RunGroup *group; TestInfo *test; - test_results_t result; + test_results_t result{}; if (strcmp(tag, COMPONENT_PROGRAM_SETUP) == 0) { args = decodeParams(params, args); result = compbe->program_setup(params); @@ -752,7 +752,7 @@ void RemoteBE::setenv_on_local(char *message) connection->send_message(buffer); } -void RemoteBE::dispatchExit(char *message) +void RemoteBE::dispatchExit(char *) { exit(0); } @@ -858,17 +858,17 @@ void RemoteOutputDriver::startNewTest(std::map &, Test assert(0); //Not expected to be called from BE } -void RemoteOutputDriver::redirectStream(TestOutputStream stream, const char * filename) +void RemoteOutputDriver::redirectStream(TestOutputStream, const char *) { assert(0); //Not expected to be called from BE } -void RemoteOutputDriver::logResult(test_results_t result, int stage) +void RemoteOutputDriver::logResult(test_results_t, int) { assert(0); //Not expected to be called from BE } -void RemoteOutputDriver::logCrash(std::string testname) +void RemoteOutputDriver::logCrash(std::string) { assert(0); //Not expected to be called from BE } @@ -1002,8 +1002,8 @@ bool sendGo(Connection *c) { } void handle_message(char *buffer) { - TestOutputStream stream; - std::string string; + TestOutputStream stream{}; + std::string string{}; buffer = decodeInt(stream, buffer); decodeString(string, buffer); diff --git a/src/remotetest.h b/src/remotetest.h index 7d7a3b59f..d18df6a42 100644 --- a/src/remotetest.h +++ b/src/remotetest.h @@ -137,10 +137,10 @@ class TESTLIB_DLL_EXPORT RemoteTestFE : public TestMutator { class TESTLIB_DLL_EXPORT RemoteBE { private: - Connection *connection; + Connection *connection{}; std::vector &groups; - std::map nameToComponent; - std::map, TestMutator *> testToMutator; + std::map nameToComponent{}; + std::map, TestMutator *> testToMutator{}; void dispatchComp(char *message); void dispatchTest(char *message); diff --git a/src/runTests-utils.C b/src/runTests-utils.C index 62c99be3f..bd96586d2 100644 --- a/src/runTests-utils.C +++ b/src/runTests-utils.C @@ -81,13 +81,13 @@ void cleanupMutatees(char *pidFilename) { } static bool timed_out; -static void sigalrm_action(int sig, siginfo_t *siginfo, void *context) { +static void sigalrm_action(int, siginfo_t*, void*) { // Note that the child has timed out and return timed_out = true; } static bool interrupted; -static void sigint_action(int sig, siginfo_t *siginfo, void *context) { +static void sigint_action(int, siginfo_t*, void*) { interrupted = true; } @@ -98,7 +98,7 @@ int CollectTestResults(vector &test_drivers, int parallel_copies) struct sigaction old_sigalrm_a; struct sigaction sigint_a; struct sigaction old_sigint_a; - int retval; + int retval{}; timed_out = false; sigalrm_a.sa_sigaction = sigalrm_action; @@ -139,7 +139,7 @@ int CollectTestResults(vector &test_drivers, int parallel_copies) else fprintf(stderr, "*** SIGINT received. Reaping children.\n"); - for (unsigned i = 0; i < parallel_copies; i++) { + for (int i = 0; i < parallel_copies; i++) { if (!test_drivers[i].pid) continue; kill(test_drivers[i].pid, SIGKILL); @@ -171,7 +171,7 @@ int CollectTestResults(vector &test_drivers, int parallel_copies) } else { child_ret = (signed char) WEXITSTATUS(child_status); } - for (unsigned i=0; i generateTestArgs(bool resume, bool useLog, - bool staticTests, string logfile, int testLimit, + bool, string logfile, int testLimit, const char *pidFilename, std::string const& hostname) { vector args; @@ -285,7 +287,7 @@ std::vector generateTestArgs(bool resume, bool useLog, void generateTestString(bool resume, bool useLog, bool staticTests, string &logfile, int testLimit, vector& child_argv, string& shellString, - char *pidFilename) + char *) { stringstream testString; if (staticTests) { diff --git a/src/runTests.C b/src/runTests.C index a2ab76f68..2873debba 100644 --- a/src/runTests.C +++ b/src/runTests.C @@ -253,7 +253,6 @@ int main(int argc, char *argv[]) setupVars(useLog, logfile); setLibPath(); - int numFailed = 0; bool failed = false; int invocation = 0; @@ -279,7 +278,7 @@ int main(int argc, char *argv[]) } test_drivers.resize(parallel_copies); - for (unsigned i=0; istartAddr()) || (-1L == s->startAddr())) + if ( (0UL == s->startAddr()) || (static_cast(-1L) == s->startAddr())) { logerror( "%s[%d]: statement with NULL startAddr: %s[%d]: %lu\n", FILE__, __LINE__, s->getFile().c_str(), s->getLine(), s->startAddr()); return false; } // check for -1L because that's used in the default statement ctor. - if ( (0 == s->endAddr()) || (-1L == s->endAddr())) + if ( (0UL == s->endAddr()) || (static_cast(-1L) == s->endAddr())) { logerror( "%s[%d]: statement with NULL endAddr: %s[%d]: %lu\n", FILE__, __LINE__, s->getFile().c_str(), s->getLine(), s->endAddr()); diff --git a/src/symtab/test_relocations.C b/src/symtab/test_relocations.C index 9404c2d02..a37fe629a 100644 --- a/src/symtab/test_relocations.C +++ b/src/symtab/test_relocations.C @@ -45,7 +45,7 @@ using namespace Dyninst; using namespace SymtabAPI; -bool resolve_libc_name(char *buf) +bool resolve_libc_name(char *) { #if defined(os_windows_test) return false; @@ -55,10 +55,10 @@ bool resolve_libc_name(char *buf) } class test_relocations_Mutator : public SymtabMutator { - std::vector relocs; - char libc_name[1024]; - Symtab *libc; - std::vector expected_libc_relocations; + std::vector relocs{}; + char libc_name[1024]{}; + Symtab *libc{}; + std::vector expected_libc_relocations{}; bool open_libc() { @@ -172,7 +172,6 @@ test_results_t test_relocations_Mutator::executeTest() for (unsigned int i = 0; i < expected_libc_relocations.size(); ++i) { - int relocation_index ; bool found = false; for (unsigned int j = 0; j < relocs.size(); ++j) { @@ -180,7 +179,6 @@ test_results_t test_relocations_Mutator::executeTest() if (relname == expected_libc_relocations[i]) { found = true; - relocation_index = i; break; } } @@ -253,7 +251,7 @@ test_results_t test_relocations_Mutator::executeTest() expected_relocs.push_back(std::string("relocation_test_function2")); //expected_relocs.push_back(std::string("relocation_test_variable1")); //expected_relocs.push_back(std::string("relocation_test_variable2")); - int num_found = 0; + size_t num_found{}; for (unsigned int i = 0; i < expected_relocs.size(); ++i) { bool foundit = false; @@ -273,7 +271,7 @@ test_results_t test_relocations_Mutator::executeTest() if (num_found != expected_relocs.size()) { - fprintf(stderr, "%s[%d]: found %d relocs, not the expected %ld\n", + fprintf(stderr, "%s[%d]: found %lu relocs, not the expected %lu\n", FILE__, __LINE__, num_found, expected_relocs.size()); return FAILED; } diff --git a/src/symtab/test_type_info.C b/src/symtab/test_type_info.C index 99aa828a6..d474938bc 100644 --- a/src/symtab/test_type_info.C +++ b/src/symtab/test_type_info.C @@ -289,7 +289,7 @@ bool test_type_info_Mutator::verify_type_array(typeArray *t, int *exp_low, int * // special case -- if low bound is zero and // highbound is -1, the array is not specified with a proper range, so // ignore - if (! (t->getLow() == 0L && t->getHigh() == -1L)) + if (! (t->getLow() == 0UL && t->getHigh() == static_cast(-1))) { logerror( "%s[%d]: bad ranges [%lu--%lu] for type %s!\n", FILE__, __LINE__, t->getLow(), t->getHigh(), tn.c_str()); @@ -307,7 +307,7 @@ bool test_type_info_Mutator::verify_type_array(typeArray *t, int *exp_low, int * if (exp_low) { - if (*exp_low != t->getLow()) + if (static_cast(*exp_low) != t->getLow()) { logerror( "%s[%d]: unexpected lowbound %d (not %d) for type %s!\n", FILE__, __LINE__, t->getLow(), *exp_low, tn.c_str()); @@ -317,7 +317,7 @@ bool test_type_info_Mutator::verify_type_array(typeArray *t, int *exp_low, int * if (exp_hi) { - if (*exp_hi != t->getHigh()) + if (static_cast(*exp_hi) != t->getHigh()) { logerror( "%s[%d]: unexpected hibound %d (not %d) for type %s!\n", FILE__, __LINE__, t->getHigh(), *exp_hi, tn.c_str()); @@ -344,7 +344,7 @@ bool test_type_info_Mutator::verify_field(Field *f) { return false; } - if (0 == f->getName().length()) { + if (0UL == f->getName().length()) { logerror("%s[%d]: unnamed field\n", FILE__, __LINE__); } @@ -423,7 +423,6 @@ bool test_type_info_Mutator::verify_field_list( std::string fieldname = f1->getName(); std::string fieldtypename = f1->getType() ? f1->getType()->getName() : ""; - Type *ft = f1->getType(); std::string expected_fieldname = (expected_fields.size() > i) ? expected_fields[i].second @@ -492,9 +491,8 @@ bool test_type_info_Mutator::verify_type_union( return true; } -bool test_type_info_Mutator::verify_type_scalar(typeScalar *t) { +bool test_type_info_Mutator::verify_type_scalar(typeScalar *) { got_type_scalar = true; - std::string &tn = t->getName(); // uh... nothing to do here.... (maybe check sizes??) diff --git a/src/test_driver.C b/src/test_driver.C index 335540f89..af897554e 100644 --- a/src/test_driver.C +++ b/src/test_driver.C @@ -88,8 +88,6 @@ char **gargv; void initModuleIfNecessary(RunGroup *group, std::vector &groups, ParameterDict ¶ms); -bool collectInvocation(Dyninst::PID mpirun_pid, int session); - int setupLogs(ParameterDict ¶ms); #if !defined(os_windows_test) @@ -342,7 +340,6 @@ bool setupConnectionToRemote(RunGroup *group, ParameterDict ¶ms) if (!result) { fprintf(stderr, "Failed to collect mutatee params\n"); } - char **c_mutatee_args = getCParams(mutatee_exec, mutatee_args); //driver params; vector driver_args; @@ -369,9 +366,6 @@ bool setupConnectionToRemote(RunGroup *group, ParameterDict ¶ms) driver_args.push_back(redirect_file); } - char **c_driver_args = getCParams(driver_exec, driver_args); - bool attach_mode = (group->createmode == USEATTACH); - result = con->server_accept(); if (!result) { fprintf(stderr, "Failed to accept connection from client\n"); @@ -655,7 +649,7 @@ void startAllTests(std::vector &groups, ParameterDict ¶m) if (param["dry_run"]->getInt()) { // StdOutputDriver does the results display - for (int gti = 0; gti < groups[i]->tests.size(); gti++) { + for (auto gti = 0UL; gti < groups[i]->tests.size(); gti++) { TestInfo *test = groups[i]->tests[gti]; const char *mode_str [] = { "create", "attach","rewriter","" }; const char *link_str [] = { "static", "dynamic" }; diff --git a/src/test_info_new.C b/src/test_info_new.C index 019abec55..7a9eeadf7 100644 --- a/src/test_info_new.C +++ b/src/test_info_new.C @@ -55,9 +55,8 @@ static const char *extract_name(const char *tag, const char *label) // The constructor for TestInfo TestInfo::TestInfo(unsigned int i, const char *iname, const char *imrname, const char *isoname, const char *ilabel) : - index(i), name(iname), mutator_name(imrname), soname(isoname), - label(ilabel), mutator(NULL), disabled(false), limit_disabled(false), - enabled(false), result_reported(false) + name(iname), mutator_name(imrname), soname(isoname), + label(ilabel), index(i) { assert(name); assert(mutator_name); @@ -71,13 +70,8 @@ TestInfo::TestInfo(unsigned int i, const char *iname, const char *imrname, } TestInfo::TestInfo(unsigned int i, const char *libsuffix, const char *ilabel) : - index(i), label(ilabel), - mutator(NULL), - disabled(false), - limit_disabled(false), - enabled(false), - result_reported(false) + index(i) { name = extract_name("test: ", label); mutator_name = extract_name("mutator: ", label); diff --git a/src/test_info_new.h b/src/test_info_new.h index 919b332dc..4661b4c69 100644 --- a/src/test_info_new.h +++ b/src/test_info_new.h @@ -96,20 +96,20 @@ class TestInfo { static int global_max_test_name_length; public: - const char *name; - const char *mutator_name; - const char *soname; - const char *label; - TestMutator *mutator; - bool disabled; - bool limit_disabled; - bool enabled; - unsigned int index; - unsigned int group_index; + const char *name{}; + const char *mutator_name{}; + const char *soname{}; + const char *label{}; + TestMutator *mutator{}; + bool disabled{false}; + bool limit_disabled{false}; + bool enabled{false}; + unsigned int index{}; + unsigned int group_index{}; - test_results_t results[NUM_RUNSTATES]; - bool result_reported; - UsageMonitor usage; + test_results_t results[NUM_RUNSTATES]{}; + bool result_reported{false}; + UsageMonitor usage{}; TESTLIB_DLL_EXPORT static int getMaxTestNameLength(); TESTLIB_DLL_EXPORT static void setMaxTestNameLength(int newlen); diff --git a/src/test_lib_soExecution.C b/src/test_lib_soExecution.C index 9534bf67b..3297eb4d3 100644 --- a/src/test_lib_soExecution.C +++ b/src/test_lib_soExecution.C @@ -110,7 +110,7 @@ static void* openSO(const char *soname, bool local) int setupMutatorsForRunGroup(RunGroup *group) { int tests_found = 0; - for (int i = 0; i < group->tests.size(); i++) { + for (size_t i = 0; i < group->tests.size(); i++) { TestInfo *test = group->tests[i]; if (test->disabled) continue; diff --git a/src/testdriver_be.C b/src/testdriver_be.C index 9c8ad4c7c..55f98df04 100644 --- a/src/testdriver_be.C +++ b/src/testdriver_be.C @@ -43,11 +43,18 @@ using namespace std; #include #include -#define log_printf(str, args...) do { if (getDebugLog()) { fprintf(getDebugLog(), str, args); fflush(getDebugLog()); } } while (0) + +template +static void log_printf(char const* str, Args... args) { + if(getDebugLog()) { + fprintf(getDebugLog(), str, args...); + fflush(getDebugLog()); + } +} static void getPortHostnameFD(int argc, char *argv[], int &port, std::string &hostname, int &fd) { - for (unsigned i=0; i