From 82349c48f4819408e1230a104f9c7b10aba25c5c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 24 Apr 2025 07:17:48 +0200 Subject: [PATCH] mds/Locker: use ceph_abort_msg() instead of ceph_assert() This ceph_assert() always fails, but depending on the configuration value `ceph_assert_supresssions`, execution may continue, but the `dir` variable is left uninitialized. This leads to a compiler warning: /home/jenkins-build/build/workspace/ceph-api/src/mds/Locker.cc:451:22: error: variable 'dir' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] clang then suggests to nullptr-initialize the variable: /home/jenkins-build/build/workspace/ceph-api/src/mds/Locker.cc:447:11: note: initialize the variable 'dir' to silence this warning 447 | CDir *dir; | ^ | = nullptr This, however, is a very bad idea because all this does is suppress the warning; it still crashes the process. Since there's no recovery from this problem, let's switch to ceph_abort_msg() which is [[noreturn]] and the compiler can deduce that `dir` is always initialized when it's used. Signed-off-by: Max Kellermann --- src/mds/Locker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index bf21af21375..7b67097ae66 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -451,7 +451,7 @@ bool Locker::acquire_locks(const MDRequestRef& mdr, } else if (CDentry *dn = dynamic_cast(object)) { dir = dn->get_dir(); } else { - ceph_assert(0 == "unknown type of lock parent"); + ceph_abort_msg("unknown type of lock parent"); } if (dir->get_inode() == mdr->lock_cache->get_dir_inode()) { // forcibly auth pin if there is lock cache on parent dir -- 2.39.5