]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
gunit/013: fix build warnings
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 19 Sep 2023 04:59:53 +0000 (10:29 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 25 Oct 2023 20:20:14 +0000 (14:20 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/gunit/013-cgroup_build_tasks_procs_path.cpp

index d5392cdcc5f7406c0b9f113a384fe9afe14c473e..59d82c9b631df1551c82a26f128aedb9da832364 100644 (file)
@@ -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;