From e12b26af640642689ef75f9b2a34d34e251a47f7 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Mon, 11 Jul 2022 17:40:29 +0900 Subject: [PATCH] Fix a SVACE reported bug Change-Id: I2056c0a36ba89214c13b6b864b6ed496cfe028d6 Signed-off-by: Unsung Lee --- src/plugin/plugin.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index 67f19e0..038886e 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -112,7 +112,10 @@ static int resource_cpu_boosting_send_command (cpu_boosting_input_t input, int s byte = send(sock, (const void *)&input, sizeof(input), 0); if (byte != sizeof(input)) { - _E("[CPU-BOOSTING-PLUGIN] error is based on %s", strerror(errno)); + char error_buf[1024]; + strerror_r(errno, error_buf, sizeof(error_buf)); + + _E("[CPU-BOOSTING-PLUGIN] error is based on %s", error_buf); _E("[CPU-BOOSTING-PLUGIN] client input size is %u, but sent size is %d", (unsigned int)sizeof(input), byte); return -1; @@ -121,7 +124,10 @@ static int resource_cpu_boosting_send_command (cpu_boosting_input_t input, int s if (input.body_size > 0) { byte = send(sock, (const void *)input.pid.tid, input.body_size, 0); if (byte != input.body_size) { - _E("[CPU-BOOSTING-PLUGIN] error is based on %s", strerror(errno)); + char error_buf[1024]; + strerror_r(errno, error_buf, sizeof(error_buf)); + + _E("[CPU-BOOSTING-PLUGIN] error is based on %s", error_buf); _E("[CPU-BOOSTING-PLUGIN] client input size is %d, but sent size is %d", input.body_size, byte); return -1; @@ -205,7 +211,10 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid, byte = recv(sock, (void *)&output, sizeof(output), 0); if (byte != sizeof(output)) { - _E("[CPU-BOOSTING-PLUGIN] error is based on %s", strerror(errno)); + char error_buf[1024]; + strerror_r(errno, error_buf, sizeof(error_buf)); + + _E("[CPU-BOOSTING-PLUGIN] error is based on %s", error_buf); _E("[CPU-BOOSTING-PLUGIN] client output size is %u, but received size is %d", (unsigned int)sizeof(output), byte); ret = -1; @@ -224,7 +233,10 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid, byte = recv(sock, (void *)level->tid_level, level->tid_count * sizeof(int), 0); if (byte != level->tid_count * sizeof(int)) { - _E("[CPU-BOOSTING-PLUGIN] error is based on %s", strerror(errno)); + char error_buf[1024]; + strerror_r(errno, error_buf, sizeof(error_buf)); + + _E("[CPU-BOOSTING-PLUGIN] error is based on %s", error_buf); _E("[CPU-BOOSTING-PLUGIN] client output size is %u, but received size is %d", level->tid_count * (unsigned int)sizeof(int), byte); free(level->tid_level); -- 2.34.1