From 9362ecc36407186182be2a967422a8bca1467cc9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 24 Jun 2025 22:38:13 +0800 Subject: [PATCH] rbd: fix unused function warning when WITH_KRBD is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Guard print_error_description() and get_unsupported_features() with `#ifdef WITH_KRBD` to prevent compiler warnings when KRBD support is not enabled. These functions are only called by do_kernel_map(), which is itself conditionally compiled. When WITH_KRBD is not defined, the compiler generates unused function warnings for these helper functions. Fixes warning: ``` /home/kefu/dev/ceph/src/tools/rbd/action/Kernel.cc:305:13: warning: ‘void rbd::action::kernel::print_error_description(const char*, const char*, const char*, const char*, int)’ defined but not used [-Wunused-function] 305 | static void print_error_description(const char *poolname, | ^~~~~~~~~~~~~~~~~~~~~~~ ``` this silences the warning. Signed-off-by: Kefu Chai --- src/tools/rbd/action/Kernel.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/rbd/action/Kernel.cc b/src/tools/rbd/action/Kernel.cc index 117f9492d0918..49bb33a58f948 100644 --- a/src/tools/rbd/action/Kernel.cc +++ b/src/tools/rbd/action/Kernel.cc @@ -270,6 +270,7 @@ static int do_kernel_list(Formatter *f) { #endif } +#ifdef WITH_KRBD static int get_unsupported_features(librbd::Image &image, uint64_t *unsupported_features) { @@ -373,6 +374,7 @@ static void print_error_description(const char *poolname, done: std::cout << "In some cases useful info is found in syslog - try \"dmesg | tail\"." << std::endl; } +#endif static int do_kernel_map(const char *poolname, const char *nspace_name, const char *imgname, const char *snapname, -- 2.39.5