simplify pointer gymnastics that sprained gcc-8

This commit is contained in:
christos 2019-11-03 03:15:59 +00:00
parent 59b3edf18c
commit ba0758a3b7
1 changed files with 6 additions and 4 deletions

View File

@ -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> * Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
@ -30,7 +30,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #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 */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -95,7 +95,8 @@ load_ptr(void *where, size_t len)
(void)memcpy(&val, where, len); (void)memcpy(&val, where, len);
#endif #endif
#if BYTE_ORDER == BIG_ENDIAN #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 #endif
return (len == sizeof(Elf_Sxword)) ? val : (Elf_Sword)val; return (len == sizeof(Elf_Sxword)) ? val : (Elf_Sword)val;
} }
@ -117,7 +118,8 @@ store_ptr(void *where, Elf_Sxword val, size_t len)
(void)memcpy(where, &val, len); (void)memcpy(where, &val, len);
#endif #endif
#if BYTE_ORDER == BIG_ENDIAN #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 #endif
} }