]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
SQUASH: mds/client: don't get clever with ceph_mds_request_head_legacy encode/decode
authorJeff Layton <jlayton@redhat.com>
Thu, 1 Sep 2016 18:18:55 +0000 (14:18 -0400)
committerJeff Layton <jlayton@redhat.com>
Thu, 1 Sep 2016 18:36:15 +0000 (14:36 -0400)
As requested by Greg...

Declare a legacy object on the stack, and do an extra copy to/from it.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/messages/MClientRequest.h

index 26f69f7f3ec7246b70776485a96e2a125450f115..00419ebb5aca4ba31d1aa42d711874625e498910 100644 (file)
@@ -165,11 +165,10 @@ public:
     if (header.version >= 4) {
       ::decode(head, p);
     } else {
-      struct ceph_mds_request_head_legacy *old_mds_head =
-       (struct ceph_mds_request_head_legacy *)&(head.oldest_client_tid);
-
-      ::decode(*old_mds_head, p);
+      struct ceph_mds_request_head_legacy old_mds_head;
 
+      ::decode(old_mds_head, p);
+      memcpy(&head.oldest_client_tid, &old_mds_head, sizeof(old_mds_head));
       head.version = 0;
 
       /* Can't set the btime from legacy struct */
@@ -197,10 +196,10 @@ public:
     if (features & CEPH_FEATURE_FS_BTIME) {
       ::encode(head, payload);
     } else {
-      struct ceph_mds_request_head_legacy *old_mds_head =
-       (struct ceph_mds_request_head_legacy *)&(head.oldest_client_tid);
+      struct ceph_mds_request_head_legacy old_mds_head;
 
-      ::encode(*old_mds_head, payload);
+      memcpy(&old_mds_head, &(head.oldest_client_tid), sizeof(old_mds_head));
+      ::encode(old_mds_head, payload);
     }
 
     ::encode(path, payload);