From bc4c18ec63806d2cdc58cb0c064857bca6b49ec0 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Tue, 19 Sep 2023 10:29:53 +0530 Subject: [PATCH] gunit/013: fix build warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix unused variable warnings and signed comparison warning across the test case: 013-cgroup_build_tasks_procs_path.cpp: In member function ‘virtual void BuildTasksProcPathTest_BuildTasksProcPathTest_CgV2_Test::TestBody()’: 013-cgroup_build_tasks_procs_path.cpp:112:27: warning: unused variable ‘ctrlr’ [-Wunused-variable] struct cgroup_controller ctrlr = {0}; ^~~~~ 013-cgroup_build_tasks_procs_path.cpp: In member function ‘virtual void BuildTasksProcPathTest_BuildTasksProcPathTest_CgV1WithNs_Test::TestBody()’: 013-cgroup_build_tasks_procs_path.cpp:126:27: warning: unused variable ‘ctrlr’ [-Wunused-variable] struct cgroup_controller ctrlr = {0}; ^~~~~ 013-cgroup_build_tasks_procs_path.cpp: In member function ‘virtual void BuildTasksProcPathTest_BuildTasksProcPathTest_CgV2WithNs_Test::TestBody()’: 013-cgroup_build_tasks_procs_path.cpp:140:27: warning: unused variable ‘ctrlr’ [-Wunused-variable] struct cgroup_controller ctrlr = {0}; ^~~~~ In file included from 013-cgroup_build_tasks_procs_path.cpp:9: ../../googletest/googletest/include/gtest/gtest.h: In instantiation of ‘testing::AssertionResult testing::internal::CmpHelperLT(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int]’: 013-cgroup_build_tasks_procs_path.cpp:53:4: required from here ../../googletest/googletest/include/gtest/gtest.h:1526:28: warning: comparison of integer expressions of different signedness: ‘const int’ and ‘const long unsigned int’ [-Wsign-compare] ../../googletest/googletest/include/gtest/gtest.h:1510:7: if (val1 op val2) {\ ~~~~~~~~~~~~ ../../googletest/googletest/include/gtest/gtest.h:1526:28: GTEST_IMPL_CMP_HELPER_(LT, <); ../../googletest/googletest/include/gtest/gtest.h:1510:12: note: in definition of macro ‘GTEST_IMPL_CMP_HELPER_’ if (val1 op val2) {\ ^~ Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- tests/gunit/013-cgroup_build_tasks_procs_path.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/gunit/013-cgroup_build_tasks_procs_path.cpp b/tests/gunit/013-cgroup_build_tasks_procs_path.cpp index d5392cdc..59d82c9b 100644 --- a/tests/gunit/013-cgroup_build_tasks_procs_path.cpp +++ b/tests/gunit/013-cgroup_build_tasks_procs_path.cpp @@ -50,7 +50,7 @@ class BuildTasksProcPathTest : public ::testing::Test { ret = snprintf(cg_mount_table[i].mount.path, FILENAME_MAX, "/sys/fs/cgroup/%s", cg_mount_table[i].name); - ASSERT_LT(ret, sizeof(cg_mount_table[i].mount.path)); + ASSERT_LT(ret, (int)sizeof(cg_mount_table[i].mount.path)); cg_mount_table[i].mount.next = NULL; @@ -109,7 +109,6 @@ TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV1) TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV2) { char ctrlname[] = "controller3"; - struct cgroup_controller ctrlr = {0}; char path[FILENAME_MAX]; char cgname[] = "tomcat"; int ret; @@ -123,7 +122,6 @@ TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV2) TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV1WithNs) { char ctrlname[] = "controller4"; - struct cgroup_controller ctrlr = {0}; char path[FILENAME_MAX]; char cgname[] = "database12"; int ret; @@ -137,7 +135,6 @@ TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV1WithNs) TEST_F(BuildTasksProcPathTest, BuildTasksProcPathTest_CgV2WithNs) { char ctrlname[] = "controller1"; - struct cgroup_controller ctrlr = {0}; char path[FILENAME_MAX]; char cgname[] = "server"; int ret; -- 2.47.2