]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include: Simplify usage of init_le16/32/64 routines
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 2 Sep 2019 19:22:09 +0000 (21:22 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 5 Sep 2019 08:50:04 +0000 (10:50 +0200)
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 <ulrich.weigand@de.ibm.com>
src/include/byteorder.h
src/msg/msg_types.h

index 8674860166864936da9aa7db9bfc8b293a1630a0..85268543143bc145112427aa43eb272210ce6077 100644 (file)
@@ -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;
 }
 
   /*
index 6ce1b3a0b2f8c57a0c2d1e94782474a8c9b5d820..68434455d9a0c9082c4cf37c9de27af796304308 100644 (file)
@@ -77,7 +77,7 @@ public:
   bool is_mgr() const { return type() == TYPE_MGR; }
 
   operator ceph_entity_name() const {
-    ceph_entity_name n = { _type, {init_le64(_num)} };
+    ceph_entity_name n = { _type, init_le64(_num) };
     return n;
   }