aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2024-04-19 14:29:12 +0000
committerStefan Eßer <se@FreeBSD.org>2024-04-19 14:47:19 +0000
commit6b13e4cb3da28be82f9d3b8bd98e229ae107c73a (patch)
tree858c1f592796f243548f82dee3bc5242ee610a8a /sbin
parent178cf4b9db4bb6726e845b10923788cf4e7a5ef0 (diff)
downloadsrc-6b13e4cb3da28be82f9d3b8bd98e229ae107c73a.tar.gz
src-6b13e4cb3da28be82f9d3b8bd98e229ae107c73a.zip
ldconfig: small optimization
Swap which side of a comparison is byte-swapped by be32toh() on little-endian architectures. The be32toh() macro just returns the operand and big-endian architectures and returns it byte-swapped on little-endian architectures. When operating on a constant argument, the compiler can perform the swap operation at build time instead of swapping the data read from the hints file at run time. Reviewed by: kib Tested by: tuexen MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D44734
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ldconfig/elfhints.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sbin/ldconfig/elfhints.c b/sbin/ldconfig/elfhints.c
index d6ee5e0918d6..64b3f916ba8d 100644
--- a/sbin/ldconfig/elfhints.c
+++ b/sbin/ldconfig/elfhints.c
@@ -220,7 +220,7 @@ read_elf_hints(const char *hintsfile, bool must_exist, bool force_be)
close(fd);
hdr = (struct elfhints_hdr *)mapbase;
- is_be = be32toh(hdr->magic) == ELFHINTS_MAGIC;
+ is_be = hdr->magic == htobe32(ELFHINTS_MAGIC);
if (COND_SWAP(hdr->magic) != ELFHINTS_MAGIC)
errx(1, "\"%s\": invalid file format", hintsfile);
if (force_be && !is_be)