From 8cefc321cdd74a27d42c970937cda71638381fcf Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 2 Sep 2019 21:22:09 +0200 Subject: [PATCH] include: Simplify usage of init_le16/32/64 routines These routines currently just return plain __u16/32/64. This patch changes them to return ceph_le16/32/64 types instead. This has a number of benefits, in particular it allows the routines to now be used to directly initialize variables of ceph_le16/32/64 type, as one would expect from the names of those routines. This doesn't make much of a difference in the current code base, but it simplifies future patches to fix endian issues. Fixes (partially): https://tracker.ceph.com/issues/41605 Signed-off-by: Ulrich Weigand (cherry picked from commit c576bb28a7744fac6d0bb02cc67c7e6542218e95) Changes from cherry-picked commit: - Change in src/msg/msg_types.h (ceph_entity_name) not needed Signed-off-by: Ulrich Weigand --- src/include/byteorder.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/include/byteorder.h b/src/include/byteorder.h index 8674860166864..85268543143bc 100644 --- a/src/include/byteorder.h +++ b/src/include/byteorder.h @@ -83,14 +83,20 @@ using ceph_le64 = ceph_le<__u64>; using ceph_le32 = ceph_le<__u32>; using ceph_le16 = ceph_le<__u16>; -inline __u64 init_le64(__u64 x) { - return mswab<__u64>(x); +inline ceph_le64 init_le64(__u64 x) { + ceph_le64 v; + v = x; + return v; } -inline __u32 init_le32(__u32 x) { - return mswab<__u32>(x); +inline ceph_le32 init_le32(__u32 x) { + ceph_le32 v; + v = x; + return v; } -inline __u16 init_le16(__u16 x) { - return mswab<__u16>(x); +inline ceph_le16 init_le16(__u16 x) { + ceph_le16 v; + v = x; + return v; } /* -- 2.39.5