Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so/arch/mips simplify pointer gymnastics that...



details:   https://anonhg.NetBSD.org/src/rev/adac22efc71a
branches:  trunk
changeset: 460764:adac22efc71a
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 03 03:15:59 2019 +0000

description:
simplify pointer gymnastics that sprained gcc-8

diffstat:

 libexec/ld.elf_so/arch/mips/mips_reloc.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 85da0e06af3f -r adac22efc71a libexec/ld.elf_so/arch/mips/mips_reloc.c
--- a/libexec/ld.elf_so/arch/mips/mips_reloc.c  Sun Nov 03 01:35:47 2019 +0000
+++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c  Sun Nov 03 03:15:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_reloc.c,v 1.72 2018/01/19 23:17:41 christos Exp $ */
+/*     $NetBSD: mips_reloc.c,v 1.73 2019/11/03 03:15:59 christos Exp $ */
 
 /*
  * Copyright 1997 Michael L. Hitch <mhitch%montana.edu@localhost>
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mips_reloc.c,v 1.72 2018/01/19 23:17:41 christos Exp $");
+__RCSID("$NetBSD: mips_reloc.c,v 1.73 2019/11/03 03:15:59 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -95,7 +95,8 @@
        (void)memcpy(&val, where, len);
 #endif
 #if BYTE_ORDER == BIG_ENDIAN
-       (void)memcpy((uint8_t *)((&val)+1) - len, where, len);
+       uint8_t *valp = (void *)&val;
+       (void)memcpy(valp + sizeof(val) - len, where, len);
 #endif
        return (len == sizeof(Elf_Sxword)) ? val : (Elf_Sword)val;
 }
@@ -117,7 +118,8 @@
        (void)memcpy(where, &val, len);
 #endif
 #if BYTE_ORDER == BIG_ENDIAN
-       (void)memcpy(where, (const uint8_t *)((&val)+1) - len, len);
+       const uint8_t *valp = (const void *)&val;
+       (void)memcpy(where, valp + sizeof(val) - len, len);
 #endif
 }
 



Home | Main Index | Thread Index | Old Index