1.6 KiB
Pre12 Batch 02
This batch replaces exactly three potentially unaligned typed loads with the FreeBSD little-endian byte decoders planned for Pre12.
xattr.c:hdrbufcontains two raw metadata bytes returned byerofs_xattr_read_backing(..., sizeof(raw_len), ...);le16dec(hdrbuf)decodes the prefix-record length.inode.c:bufcontains at least one complete 32-byte compact on-disk inode returned byerofs_read_metadata; its first two bytes are the little-endiani_formatfield decoded byle16dec(buf).data.c: the non-indexes branch setsentry_sizetoEROFS_BLOCK_MAP_ENTRY_SIZE == sizeof(__le32) == 4;idxpoints to those four raw block-map bytes andle32dec(idx)decodes the block address.
For bytes b0..b3, both old expressions and the new helpers produce
b0 | b1 << 8 or b0 | b1 << 8 | b2 << 16 | b3 << 24. On a little-endian
host the typed load already has that value; on a big-endian host leXXtoh
byte-swaps the typed value to that same formula. The helpers preserve this
result while avoiding any alignment requirement.
xattr.c and data.c receive the helpers through internal.h to
erofs_fs.h to <sys/endian.h>; inode.c also includes <sys/endian.h>
directly. Existing le16dec and le32dec consumers confirm the established
include convention. Error checks, branches, value ranges, and buffer release
ordering are unchanged. No point was skipped and no other endian read was
changed.
Validation used exact-expression counts, buffer-source and length inspection,
symbolic endian equivalence, source-diff inspection, and git diff --check.
No build, QEMU, smoke, feature, or other dynamic test was run.