]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
dout: declare dpp using `decltype(auto)` instead of `auto` 22207/head
authorKefu Chai <kchai@redhat.com>
Thu, 24 May 2018 09:21:42 +0000 (17:21 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 24 May 2018 09:31:13 +0000 (17:31 +0800)
this makes `pdpp` an alias of `dpp`, guess this ensure GCC that the
returned `sub` is a constant.

In file included from /home/kefu/dev/ceph/src/kv/LevelDBStore.h:25,
                 from /home/kefu/dev/ceph/src/kv/KeyValueDB.cc:6:
/home/kefu/dev/ceph/src/osd/osd_types.h: In lambda function:
/home/kefu/dev/ceph/src/common/dout.h:101:75: error: the value of ‘pdpp’
is not usable in a constant expression
     dout_impl(pdpp->get_cct(),
ceph::dout::need_dynamic(pdpp->get_subsys()), v) \
                                                                           ^
/home/kefu/dev/ceph/src/common/dout.h:81:58: note: in definition of
macro ‘dout_impl’
       return (cctX->_conf->subsys.template should_gather<sub, v>()); \
                                                          ^~~
/home/kefu/dev/ceph/src/osd/osd_types.h:2992:3: note: in expansion of
macro ‘ldpp_dout’
   ldpp_dout(dpp, 10) << "build_prior all_probe " << all_probe << dendl;
   ^~~~~~~~~
/home/kefu/dev/ceph/src/common/dout.h:100:12: note: ‘pdpp’ was not
declared ‘constexpr’
   if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for
'this' */ \
            ^~~~
/home/kefu/dev/ceph/src/common/dout.h:100:12: note: in definition of
macro ‘ldpp_dout’
   if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for
'this' */ \
            ^~~~

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/dout.h

index d284995f9fa590c097f666347344a4fb149bc332..e0114e69dfc08bf02b1b2532252fd72aa33241ef 100644 (file)
@@ -97,7 +97,7 @@ struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
 #define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix
 
 #define ldpp_dout(dpp, v)                                              \
-  if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \
+  if (decltype(auto) pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \
     dout_impl(pdpp->get_cct(), ceph::dout::need_dynamic(pdpp->get_subsys()), v) \
       pdpp->gen_prefix(*_dout)