]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/rdma: set/get silence warning 26581/head
authorKefu Chai <kchai@redhat.com>
Fri, 22 Feb 2019 05:18:48 +0000 (13:18 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Feb 2019 05:41:25 +0000 (13:41 +0800)
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 <kchai@redhat.com>
src/msg/async/rdma/Infiniband.cc
src/msg/async/rdma/Infiniband.h

index 858cdd1aa4df3842351e8fb95b95850665cfca62..279d3bbb14f29ccea644dcc9f51a0c5e6087c974 100644 (file)
@@ -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()
index 2889cdfc66e970239bad423012d4f37f560e195b..a43d9c5b757bacc5d7e4d97f573d432b77104d58 100644 (file)
@@ -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;