]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
log/Log: cast typed pointer to integer before printing it 38097/head
authorKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 07:21:19 +0000 (15:21 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 09:24:44 +0000 (17:24 +0800)
commitcc3eeef1886500b5efc54c0a34e9b3c89bd7aa35
tree96e593cbb8c1f0cb1f909c30772cc03045d6c83e
parent7ba8a611e92688abaa55001a9e59d13e55b32d78
log/Log: cast typed pointer to integer before printing it

libfmt does not print pointer if it's not "void*", but "thread_t" is
defined as a pointer pointing to "struct pthread" on FreeBSD, so we need
to cast it either to "void*" or an integer". let's cast it to an integer
so it's more consistent with the output on Linux where thread_t is
defined as an integer.

this change addresses the FTBFS on FreeBSD likee:

In file included from /home/jenkins/workspace/ceph-master-compile/src/log/Log.cc:27:
In file included from /usr/local/include/fmt/format.h:44:
/usr/local/include/fmt/core.h:1043:20: error: invalid application of 'sizeof' to an incomplete type 'pthread'
    static_assert(!sizeof(T), "formatting of non-void pointers is disallowed");
                   ^~~~~~~~~
/usr/local/include/fmt/core.h:1259:32: note: in instantiation of function template specialization
'fmt::v7::detail::arg_mapper<fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<char> >, char> >::map<pthread>' requested here
  return arg_mapper<Context>().map(val);
                               ^
/usr/local/include/fmt/core.h:1408:23: note: in instantiation of function template specialization 'fmt::v7::detail::make_arg<true,
fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<char> >, char>, fmt::v7::detail::type::int_type, pthread *, 0>' requested here
        data_{detail::make_arg<
                      ^
/usr/local/include/fmt/core.h:1764:10: note: in instantiation of member function 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<char>
>, char>, pthread *const, char *>::format_arg_store' requested here
  return {args...};
         ^
/usr/local/include/fmt/core.h:1835:31: note: in instantiation of function template specialization 'fmt::v7::detail::make_args_checked<pthread *const &, char *, char [10], char>' requested here
  const auto& vargs = detail::make_args_checked<Args...>(format_str, args...);
                              ^
/home/jenkins/workspace/ceph-master-compile/src/log/Log.cc:376:23: note: in instantiation of function template specialization 'fmt::v7::format<char [10], pthread *const &, char *, char>' requested
here
    _log_message(fmt::format("  {} / {}", pthread_id, (char*)pthread_name), true);
                      ^
/usr/include/sys/_pthreadtypes.h:46:8: note: forward declaration of 'pthread'
struct pthread;
       ^
1 error generated.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/log/Log.cc