Re: [PATCH] dm vdo: use kernel byteswapping routines instead of GCC ones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/20/24 23:52, Eric Biggers wrote:
On Wed, Mar 20, 2024 at 05:44:05PM -0400, Matthew Sakai wrote:
  static __always_inline u64 getblock64(const u64 *p, int i)
  {
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-	return p[i];
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-	return __builtin_bswap64(p[i]);
-#else
-#error "can't figure out byte order"
-#endif
+	return le64_to_cpup(&p[i]);
  }
static __always_inline void putblock64(u64 *p, int i, u64 value)
  {
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-	p[i] = value;
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-	p[i] = __builtin_bswap64(value);
-#else
-#error "can't figure out byte order"
-#endif
+	p[i] = cpu_to_le64(value);
  }

This is very broken.  What you're actually looking for is get_unaligned_le64()
and put_unaligned_le64().  And they should be folded directly into the caller.

- Eric


Thanks for the suggestion. We'll work on a v2 to include this.

Matt





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux