]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Move cleanbin() function to common/util.cc
authorDavid Zafman <dzafman@redhat.com>
Tue, 30 Aug 2016 18:05:16 +0000 (11:05 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 9 Feb 2017 17:16:07 +0000 (09:16 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 5c79074ffaee34b2956d9dfc67b1eff9f39b47f3)

Conflicts:
src/tools/CMakeLists.txt (changes goes in src/CMakeLists.txt)

src/CMakeLists.txt
src/common/util.cc
src/include/util.h
src/tools/ceph_objectstore_tool.cc

index ca0319456a804a97692552b5abb03af9fad97b6f..868d65df4481076d570f2fcdf587700fb109de27 100644 (file)
@@ -476,6 +476,7 @@ set(rados_srcs
   tools/RadosDump.cc
   tools/rados/RadosImport.cc
   tools/rados/PoolDump.cc
+  common/util.cc
   common/obj_bencher.cc)
 add_executable(rados ${rados_srcs})
 target_link_libraries(rados librados global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} libradosstriper)
index ee4b84e87b517d82c50f42ccafbe4e4fe27f7dac..a3a42b362d8f0acfce4b15f042c8f4c8129d13dd 100644 (file)
@@ -263,3 +263,26 @@ void dump_services(Formatter* f, const map<string, list<int> >& services, const
   }
   f->close_section();
 }
+
+// Convert non-printable characters to '\###'
+void cleanbin(string &str)
+{
+  bool cleaned = false;
+  string clean;
+
+  for (string::iterator it = str.begin(); it != str.end(); ++it) {
+    if (!isprint(*it)) {
+      clean.push_back('\\');
+      clean.push_back('0' + ((*it >> 6) & 7));
+      clean.push_back('0' + ((*it >> 3) & 7));
+      clean.push_back('0' + (*it & 7));
+      cleaned = true;
+    } else {
+      clean.push_back(*it);
+    }
+  }
+
+  if (cleaned)
+    str = clean;
+  return;
+}
index fa8dd244f06ed665dde57fdc3b11e50aeb6795d0..13339c7bd31041b4d3c031a0eebab86f26a780d6 100644 (file)
@@ -81,4 +81,5 @@ void collect_sys_info(map<string, string> *m, CephContext *cct);
 /// @param type the service type of given @p services, for example @p osd or @p mon.
 void dump_services(Formatter* f, const map<string, list<int> >& services, const char* type);
 
+void cleanbin(string &str);
 #endif /* CEPH_UTIL_H */
index f3714a655499d118d6e91c2e010b2030d9e3c6f9..908327810a698949ad4dd6e3349c15f911787e66 100644 (file)
@@ -41,6 +41,7 @@
 #include "rebuild_mondb.h"
 #include "ceph_objectstore_tool.h"
 #include "include/compat.h"
+#include "include/util.h"
 
 namespace po = boost::program_options;
 using namespace std;
@@ -295,29 +296,6 @@ bool debug = false;
 super_header sh;
 uint64_t testalign;
 
-// Convert non-printable characters to '\###'
-static void cleanbin(string &str)
-{
-  bool cleaned = false;
-  string clean;
-
-  for (string::iterator it = str.begin(); it != str.end(); ++it) {
-    if (!isprint(*it)) {
-      clean.push_back('\\');
-      clean.push_back('0' + ((*it >> 6) & 7));
-      clean.push_back('0' + ((*it >> 3) & 7));
-      clean.push_back('0' + (*it & 7));
-      cleaned = true;
-    } else {
-      clean.push_back(*it);
-    }
-  }
-
-  if (cleaned)
-    str = clean;
-  return;
-}
-
 static int get_fd_data(int fd, bufferlist &bl)
 {
   uint64_t total = 0;