From: Kefu Chai Date: Fri, 22 Feb 2019 05:18:48 +0000 (+0800) Subject: msg/async/rdma: set/get silence warning X-Git-Tag: v15.0.0~231^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8991c73c6b26569d9226abbecbd04ad450c9388a;p=ceph.git msg/async/rdma: set/get silence warning functions like gid_to_wire_gid() is not aware of the alignment of the IBSYNMsg, so we should pass the enclosing structure to it. to silence warnings like: ceph/src/msg/async/rdma/Infiniband.cc: In member function ‘int Infiniband::send_msg(CephContext*, int, IBSYNMsg&)’: ssd/ceph/src/msg/async/rdma/Infiniband.cc:1123:19: warning: taking address of packed member of ‘IBSYNMsg’ may result in an unaligned pointer value [-Waddress-of-packed- member] 1123 | gid_to_wire_gid(&(im.gid), gid); | ^~~~~~~~~ Signed-off-by: Kefu Chai --- diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index 858cdd1aa4df..279d3bbb14f2 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -1106,7 +1106,7 @@ int Infiniband::recv_msg(CephContext *cct, int sd, IBSYNMsg& im) r = -EINVAL; } else { // valid message sscanf(msg, "%hx:%x:%x:%x:%s", &(im.lid), &(im.qpn), &(im.psn), &(im.peer_qpn),gid); - wire_gid_to_gid(gid, &(im.gid)); + wire_gid_to_gid(gid, &im); ldout(cct, 5) << __func__ << " recevd: " << im.lid << ", " << im.qpn << ", " << im.psn << ", " << im.peer_qpn << ", " << gid << dendl; } return r; @@ -1120,7 +1120,7 @@ int Infiniband::send_msg(CephContext *cct, int sd, IBSYNMsg& im) char msg[TCP_MSG_LEN]; char gid[33]; retry: - gid_to_wire_gid(&(im.gid), gid); + gid_to_wire_gid(im, gid); sprintf(msg, "%04x:%08x:%08x:%08x:%s", im.lid, im.qpn, im.psn, im.peer_qpn, gid); ldout(cct, 10) << __func__ << " sending: " << im.lid << ", " << im.qpn << ", " << im.psn << ", " << im.peer_qpn << ", " << gid << dendl; @@ -1149,7 +1149,7 @@ retry: return 0; } -void Infiniband::wire_gid_to_gid(const char *wgid, union ibv_gid *gid) +void Infiniband::wire_gid_to_gid(const char *wgid, IBSYNMsg* im) { char tmp[9]; uint32_t v32; @@ -1158,14 +1158,14 @@ void Infiniband::wire_gid_to_gid(const char *wgid, union ibv_gid *gid) for (tmp[8] = 0, i = 0; i < 4; ++i) { memcpy(tmp, wgid + i * 8, 8); sscanf(tmp, "%x", &v32); - *(uint32_t *)(&gid->raw[i * 4]) = ntohl(v32); + *(uint32_t *)(&im->gid.raw[i * 4]) = ntohl(v32); } } -void Infiniband::gid_to_wire_gid(const union ibv_gid *gid, char wgid[]) +void Infiniband::gid_to_wire_gid(const IBSYNMsg& im, char wgid[]) { for (int i = 0; i < 4; ++i) - sprintf(&wgid[i * 8], "%08x", htonl(*(uint32_t *)(gid->raw + i * 4))); + sprintf(&wgid[i * 8], "%08x", htonl(*(uint32_t *)(im.gid.raw + i * 4))); } Infiniband::QueuePair::~QueuePair() diff --git a/src/msg/async/rdma/Infiniband.h b/src/msg/async/rdma/Infiniband.h index 2889cdfc66e9..a43d9c5b757b 100644 --- a/src/msg/async/rdma/Infiniband.h +++ b/src/msg/async/rdma/Infiniband.h @@ -363,8 +363,8 @@ class Infiniband { Device *device = NULL; ProtectionDomain *pd = NULL; DeviceList *device_list = nullptr; - void wire_gid_to_gid(const char *wgid, union ibv_gid *gid); - void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]); + void wire_gid_to_gid(const char *wgid, IBSYNMsg* im); + void gid_to_wire_gid(const IBSYNMsg& im, char wgid[]); CephContext *cct; Mutex lock; bool initialized = false;