From ac72762af4a6b2b43a0374925c8eb815d315c8e2 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 5 Feb 2021 18:43:23 +0000 Subject: [PATCH] tools/rados: replace omap_key_pretty with prettify(). Signed-off-by: Radoslaw Zarzynski (cherry picked from commit cca92228f279d1334207b5e1f4bcfa225dca7f11) --- src/tools/rados/rados.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index bb6caa172eb70..c386bf9c3a427 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -1888,7 +1888,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, const char *output = NULL; bool omap_key_valid = false; std::string omap_key; - std::string omap_key_pretty; std::optional obj_name; bool with_reference = false; @@ -2103,11 +2102,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, omap_key_valid = true; omap_key = std::string(indata.c_str(), indata.length()); - omap_key_pretty = omap_key; - if (std::find_if_not(omap_key.begin(), omap_key.end(), - (int (*)(int))isprint) != omap_key.end()) { - omap_key_pretty = "(binary key)"; - } } i = opts.find("obj-name-file"); if (i != opts.end()) { @@ -2825,7 +2819,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, string oid(nargs[1]); if (!omap_key_valid) { omap_key = nargs[2]; - omap_key_pretty = omap_key; } bufferlist bl; @@ -2847,7 +2840,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, ret = io_ctx.omap_set(oid, values); if (ret < 0) { cerr << "error setting omap value " << pool_name << "/" << oid << "/" - << omap_key_pretty << ": " << cpp_strerror(ret) << std::endl; + << prettify(omap_key) << ": " << cpp_strerror(ret) << std::endl; return 1; } else { ret = 0; @@ -2862,7 +2855,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, if (!omap_key_valid) { omap_key = nargs[obj_name ? 1 : 2]; - omap_key_pretty = omap_key; } set keys; @@ -2880,7 +2872,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, ret = io_ctx.omap_get_vals_by_keys(*obj_name, keys, &values); if (ret < 0) { cerr << "error getting omap value " << pool_name << "/" << prettify(*obj_name) << "/" - << omap_key_pretty << ": " << cpp_strerror(ret) << std::endl; + << prettify(omap_key) << ": " << cpp_strerror(ret) << std::endl; return 1; } else { ret = 0; @@ -2898,7 +2890,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, ret = 0; } else { cout << "No such key: " << pool_name << "/" << prettify(*obj_name) << "/" - << omap_key_pretty << std::endl; + << prettify(omap_key) << std::endl; return 1; } } else if (strcmp(nargs[0], "rmomapkey") == 0) { @@ -2911,7 +2903,6 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, if (!omap_key_valid) { omap_key = nargs[obj_name ? 1 : 2]; - omap_key_pretty = omap_key; } if (!obj_name) { obj_name = nargs[1]; @@ -2922,7 +2913,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, ret = io_ctx.omap_rm_keys(*obj_name, keys); if (ret < 0) { cerr << "error removing omap key " << pool_name << "/" << prettify(*obj_name) << "/" - << omap_key_pretty << ": " << cpp_strerror(ret) << std::endl; + << prettify(omap_key) << ": " << cpp_strerror(ret) << std::endl; return 1; } else { ret = 0; -- 2.39.5