diff --git a/host/smartperf/client/client_command/Temperature.cpp b/host/smartperf/client/client_command/Temperature.cpp index a8a82af3803a513b72a271c6654872389b35c97e..a141fa8f3802ab51378bf6e0610feba8a4c21e54 100644 --- a/host/smartperf/client/client_command/Temperature.cpp +++ b/host/smartperf/client/client_command/Temperature.cpp @@ -27,6 +27,7 @@ std::map Temperature::ItemData() std::vector dirs; if (dp == nullptr) { LOGE("Open directory failed!"); + return {}; } while ((dirp = readdir(dp)) != nullptr) { if (strcmp(dirp->d_name, ".") != 0 && strcmp(dirp->d_name, "..") != 0) { diff --git a/host/smartperf/client/client_command/client_control.cpp b/host/smartperf/client/client_command/client_control.cpp index 11af5dce3284cbdee29832b2a67cd7a86bbda485..8b585add07a2f2778b618c988b4b094213e352cf 100644 --- a/host/smartperf/client/client_command/client_control.cpp +++ b/host/smartperf/client/client_command/client_control.cpp @@ -42,8 +42,8 @@ int ClientControl::SocketStart(const std::string &args) read(clientSocket, buffer, numBuff); LOGD("start-stop recv : %s", buffer); char dest[arraySize] = {0}; - size_t i; - for (i = 0; buffer[i] != '\0' && i < arraySize - 1; i++) { + size_t i = 0; + for (; buffer[i] != '\0' && i < arraySize - 1; i++) { dest[i] = buffer[i]; } dest[i] = '\0'; @@ -64,8 +64,8 @@ int ClientControl::SocketStop() send(clientSocket, message2, strlen(message2), 0); read(clientSocket, buffer, numBuff); char dest[arraySize] = {0}; - size_t i; - for (i = 0; buffer[i] != '\0' && i < arraySize - 1; i++) { + size_t i = 0; + for (; buffer[i] != '\0' && i < arraySize - 1; i++) { dest[i] = buffer[i]; } dest[i] = '\0'; diff --git a/host/smartperf/client/client_command/test/unittest/smartperf_main_test.cpp b/host/smartperf/client/client_command/test/unittest/smartperf_main_test.cpp index 7820ceb3a7503591a6ab9a9505d8c9ebb6c0d1c3..9796dd267fa92caa33a38cc4e0dcc4498bdcb7e2 100644 --- a/host/smartperf/client/client_command/test/unittest/smartperf_main_test.cpp +++ b/host/smartperf/client/client_command/test/unittest/smartperf_main_test.cpp @@ -38,7 +38,7 @@ public: void TearDown() {} }; -std::string &g_getOptions(std::vector &argv) +std::string g_getOptions(std::vector &argv) { std::string str = ""; std::string strFlag;