git: 6b13e4cb3da2 - main - ldconfig: small optimization
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Apr 2024 14:55:44 UTC
The branch main has been updated by se:
URL: https://cgit.FreeBSD.org/src/commit/?id=6b13e4cb3da28be82f9d3b8bd98e229ae107c73a
commit 6b13e4cb3da28be82f9d3b8bd98e229ae107c73a
Author: Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2024-04-19 14:29:12 +0000
Commit: Stefan Eßer <se@FreeBSD.org>
CommitDate: 2024-04-19 14:47:19 +0000
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
---
sbin/ldconfig/elfhints.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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)