]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: fix compilation warnings in numa.cc 58704/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 26 Jan 2022 19:10:43 +0000 (19:10 +0000)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Sun, 21 Jul 2024 14:37:42 +0000 (16:37 +0200)
```
[141/1591] Building CXX object src/common/CMakeFiles/common-common-objs.dir/numa.cc.o
In file included from ../src/include/types.h:63,
                 from ../src/include/stringify.h:7,
                 from ../src/common/numa.cc:10:
../src/common/numa.cc: In function ‘std::string get_task_comm(pid_t)’:
../src/common/numa.cc:176:12: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘long unsigned int’ [-Wsign-compare]
  176 |   assert(n <= sizeof(name));
      |          ~~^~~~~~~~~~~~~~~
../src/common/numa.cc: At global scope:
../src/common/numa.cc:159:20: warning: ‘std::string get_task_comm(pid_t)’ defined but not used [-Wunused-function]
  159 | static std::string get_task_comm(pid_t tid)
      |                    ^~~~~~~~~~~~~

```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 718607457994046f03cf0459517355c82391ed87)

src/common/numa.cc

index 7af8247f2a531165b3aa8fd6140cf4cafcceafda..f62f0d010b7874bc70b089e1c10cc3c2fdc8c857 100644 (file)
@@ -156,6 +156,7 @@ static int easy_readdir(const std::string& dir, std::set<std::string> *out)
   return 0;
 }
 
+#ifdef HAVE_DPDK
 static std::string get_task_comm(pid_t tid)
 {
   static const char* comm_fmt = "/proc/self/task/%d/comm";
@@ -173,7 +174,7 @@ static std::string get_task_comm(pid_t tid)
   if (n < 0) {
     return "";
   }
-  assert(n <= sizeof(name));
+  assert(static_cast<size_t>(n) <= sizeof(name));
   if (name[n - 1] == '\n') {
     name[n - 1] = '\0';
   } else {
@@ -181,6 +182,7 @@ static std::string get_task_comm(pid_t tid)
   }
   return name;
 }
+#endif
 
 int set_cpu_affinity_all_threads(size_t cpu_set_size, cpu_set_t *cpu_set)
 {