From: Jeff Layton Date: Thu, 1 Sep 2016 18:18:55 +0000 (-0400) Subject: SQUASH: mds/client: don't get clever with ceph_mds_request_head_legacy encode/decode X-Git-Tag: v11.0.1~326^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=44b102f9e2e2acb854899903557068482afdf0fa;p=ceph.git SQUASH: mds/client: don't get clever with ceph_mds_request_head_legacy encode/decode As requested by Greg... Declare a legacy object on the stack, and do an extra copy to/from it. Signed-off-by: Jeff Layton --- diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 26f69f7f3ec7..00419ebb5aca 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -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);