]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
msg/msg_types.h: do not cast `ceph_entity_name` to `entity_name_t` for printing 31275/head
authorKefu Chai <kchai@redhat.com>
Thu, 7 Feb 2019 13:13:14 +0000 (21:13 +0800)
committerDavid Zafman <dzafman@redhat.com>
Thu, 31 Oct 2019 13:28:04 +0000 (06:28 -0700)
commit05f80670989c0b14ff225fa967df624596e1ef9b
tree9f01edceb5306173e6429e758494e80a562b117d
parente98c06b894aa179d30844be644bd809448f5bfc6
msg/msg_types.h: do not cast `ceph_entity_name` to `entity_name_t` for printing

in GCC-9, `-Waddress-of-packed-member` is enabled, so we have warnings like:

src/msg/msg_types.h:142:41: warning: converting a packed 'const
ceph_entity_name' pointer (alignment 1) to a 'const entity_name_t'
pointer (alignment 8) may result in an unaligned pointer value
[-Waddress-of-packed-member]
  142 |   return out << *(const entity_name_t*)&addr;
      |                                         ^~~~

since the alignment of these two structures are different, we cannot
cast a structure with the alignment of 1 to a structure with the
alignment of 8. as the code generated by compiler accessing the members
of alignment 8 won't work with the members of alignment 1, we need to
create a temporary structure for printing it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit f1bfe9dbad669faacfde4e74f38fe92253e5a91e)
src/msg/msg_types.h