fs: use get_unaligned_* helpers
PATCH 7/8 fs: use get_unaligned_* helpers
--- fs/partitions/ldm.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/partitions/ldm.h +3 -3
@@ -99,9 +99,9 @@ struct parsed_partitions;#define TOC_BITMAP2 "log"/* bitmaps in the TOCBLOCK. */ /* Most numbers we deal with are big-endian and won't be aligned. */ -#define BE16 (x) ((u16)be16_to_cpu(get_unaligned((__be16*)(x)))) -#define BE32 (x) ((u32)be32_to_cpu(get_unaligned((__be32*)(x)))) -#define BE64 (x) ((u64)be64_to_cpu(get_unaligned((__be64*)(x)))) +#define BE16 (x) get_unaligned_be16((x)) +#define BE32 (x) get_unaligned_be32((x)) +#define BE64 (x) get_unaligned_be64((x))/* Borrowed from msdos.c */ #define SYS_IND (p) (get_unaligned(&(p)->sys_ind))
Signature · 1 line
1.5.5.1.350.gbbbf
Quoted 4 lines · Harvey Harrison
fs/partitions/ldm.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/partitions/ldm.h +0
-0
...
fs/partitions/ldm.h struct parsed_partitions; · line 104
Quoted 7 lines
/* Most numbers we deal with are big-endian and won't be aligned. */
fs/partitions/ldm.h +3
-3-#define BE16 (x) ((u16)be16_to_cpu(get_unaligned((__be16*)(x)))) -#define BE32 (x) ((u32)be32_to_cpu(get_unaligned((__be32*)(x)))) -#define BE64 (x) ((u64)be64_to_cpu(get_unaligned((__be64*)(x)))) +#define BE16 (x) get_unaligned_be16((x)) +#define BE32 (x) get_unaligned_be32((x)) +#define BE64 (x) get_unaligned_be64((x))
Why the double parentheses?
More importantly, I would say ldm.c should rather use get_unaligned_be*() directly. No need to hide what these macros are about by using a local alias.
After that, ldm.c should be inspected for whether really all of the accesses are unaligned. If there are any which are guaranteed to be aligned, they should of course be turned into be*_to_cpu(). But separately from this conversion to get_unaligned_be*().
Signature · 3 lines
Stefan Richter -=====-==--- -=-= ---=- http://arcgraph.de/sr/
Quoted 6 lines · Stefan Richter
Quoted 4 lines · Harvey Harrison
fs/partitions/ldm.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/partitions/ldm.h +0
-0...
Quoted 9 lines
fs/partitions/ldm.h struct parsed_partitions; · line 104
Quoted 7 lines
/* Most numbers we deal with are big-endian and won't be aligned. */
fs/partitions/ldm.h +3
-3-#define BE16 (x) ((u16)be16_to_cpu(get_unaligned((__be16*)(x)))) -#define BE32 (x) ((u32)be32_to_cpu(get_unaligned((__be32*)(x)))) -#define BE64 (x) ((u64)be64_to_cpu(get_unaligned((__be64*)(x)))) +#define BE16 (x) get_unaligned_be16((x)) +#define BE32 (x) get_unaligned_be32((x)) +#define BE64 (x) get_unaligned_be64((x))Why the double parentheses?
No reason.
Quoted 4 lines
More importantly, I would say
ldm.cshould rather use get_unaligned_be*() directly. No need to hide what these macros are about by using a local alias.
Done, will send out a revised set.
Quoted 5 lines
After that,
ldm.cshould be inspected for whether really all of the accesses are unaligned. If there are any which are guaranteed to be aligned, they should of course be turned into be*_to_cpu(). But separately from this conversion to get_unaligned_be*().
It looks like they are all needed from a quick inspection, the comments seem to suggest that lots of the accesses will be unaligned.
Cheers,
Harvey