From af9c3d2698e290dd4c00643d3d6b8a30643c708c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=9B=BD=E4=BA=AE?= Date: Sat, 6 Sep 2025 11:13:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 牛国亮 --- .../device_command/cmds/src/client_control.cpp | 8 ++++---- .../device_command/collector/src/Temperature.cpp | 1 + .../device_command/test/unittest/smartperf_main_test.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/smartperf_device/device_command/cmds/src/client_control.cpp b/smartperf_device/device_command/cmds/src/client_control.cpp index 11af5dce3..cc2d57f44 100644 --- a/smartperf_device/device_command/cmds/src/client_control.cpp +++ b/smartperf_device/device_command/cmds/src/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 (i; 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 (i; buffer[i] != '\0' && i < arraySize - 1; i++) { dest[i] = buffer[i]; } dest[i] = '\0'; diff --git a/smartperf_device/device_command/collector/src/Temperature.cpp b/smartperf_device/device_command/collector/src/Temperature.cpp index a8a82af38..a141fa8f3 100644 --- a/smartperf_device/device_command/collector/src/Temperature.cpp +++ b/smartperf_device/device_command/collector/src/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/smartperf_device/device_command/test/unittest/smartperf_main_test.cpp b/smartperf_device/device_command/test/unittest/smartperf_main_test.cpp index 7820ceb3a..9796dd267 100644 --- a/smartperf_device/device_command/test/unittest/smartperf_main_test.cpp +++ b/smartperf_device/device_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; -- Gitee From a5b672cab7ebb6d1301189687bc5ab18f8bce962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=9B=BD=E4=BA=AE?= Date: Sat, 6 Sep 2025 12:06:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 牛国亮 --- smartperf_device/device_command/cmds/src/client_control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smartperf_device/device_command/cmds/src/client_control.cpp b/smartperf_device/device_command/cmds/src/client_control.cpp index cc2d57f44..8b585add0 100644 --- a/smartperf_device/device_command/cmds/src/client_control.cpp +++ b/smartperf_device/device_command/cmds/src/client_control.cpp @@ -43,7 +43,7 @@ int ClientControl::SocketStart(const std::string &args) LOGD("start-stop recv : %s", buffer); char dest[arraySize] = {0}; size_t i = 0; - for (i; buffer[i] != '\0' && i < arraySize - 1; i++) { + for (; buffer[i] != '\0' && i < arraySize - 1; i++) { dest[i] = buffer[i]; } dest[i] = '\0'; @@ -65,7 +65,7 @@ int ClientControl::SocketStop() read(clientSocket, buffer, numBuff); char dest[arraySize] = {0}; size_t i = 0; - for (i; buffer[i] != '\0' && i < arraySize - 1; i++) { + for (; buffer[i] != '\0' && i < arraySize - 1; i++) { dest[i] = buffer[i]; } dest[i] = '\0'; -- Gitee