squashfs_swap: Use explicit sizeof(struct xxx) rather than sizeof(*s)

Many years ago when Squashfs used bitfields the copying swap
macros relied on s(ource) (the first parameter) to be a pointer
to the appropriate structure type.  Beginning with the removal
of the bitfields the swap macros were rewritten, and over
a number of iterations the need for s to be a pointer to the
appropriate type has been removed - except for one vestigal (*)
requirement, when the host is a little endian system but the
destination/source is unaligned, no swapping is
required and memcpy is used to copy from the source
buffer to the destination buffer.  This code still requires
s to be pointer of the appropriate structure type to compute
the size of the memcpy, but, this is unnecessary, so replace
it with an explicit sizeof(struct xxx).  This finally removes
any requirement for either s(ource) or d(estination) to be of
any type.

(*) Note: the new SQUASHFS_INSWAP_XXX macros that were added
at the time of the macro rewrite to more efficiently swap
inplace rather than copying (where possible) still require the
passed pointer to be of the correct type, but, this is entirely
correct as the code by definition relies on a correctly aligned
structure of the appropriate type.

The whole point of removing the need for pointer typing from the
copying macros is it should prevent the compiler from making
assumptions about alignment based on type.  Problems with this
on ARM is what prompted the initial changes!

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
1 file changed
tree: ca4e5e94713670934453c3d296fb63e711c35de7
  1. kernel/
  2. kernel-2.4/
  3. squashfs-tools/
  4. README