This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] getenv.c: Avoid check for unknown endianness.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 31 Jan 2013 11:52:25 -0500
- Subject: [PATCH] getenv.c: Avoid check for unknown endianness.
This is a small code cleanup.
We only ever support big or little endian, and we should not
check for a weird 3rd byte order. If such an error check were to
happen it would happen in a central location or at configure
time.
The following patch removes check for the big endian case, and
makes it assume that !__LITTLE_ENDIAN == __BIG_ENDIAN.
No regressions on x86_64.
OK?
2012-01-31 Carlos O'Donell <carlos@redhat.com>
* stdlib/getenv.c (getenv): Assume __BIG_ENDIAN in the
else clause and remove check for non-standard endianness.
diff --git a/stdlib/getenv.c b/stdlib/getenv.c
index ee9d2b3..f33c22f 100644
--- a/stdlib/getenv.c
+++ b/stdlib/getenv.c
@@ -48,11 +48,7 @@ getenv (name)
#if __BYTE_ORDER == __LITTLE_ENDIAN || !_STRING_ARCH_unaligned
name_start = ('=' << 8) | *(const unsigned char *) name;
#else
-# if __BYTE_ORDER == __BIG_ENDIAN
name_start = '=' | ((*(const unsigned char *) name) << 8);
-# else
- #error "Funny byte order."
-# endif
#endif
for (ep = __environ; *ep != NULL; ++ep)
{
---
Cheers,
Carlos.