Date: Tue, 12 Jan 2016 17:42:48 -0800 From: Conrad Meyer <cem@FreeBSD.org> To: Ian Lepore <ian@freebsd.org> Cc: Steven Hartland <steven@multiplay.co.uk>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r293724 - in head/sys/boot: arm64/libarm64 common efi/boot1 efi/fdt efi/include efi/include/arm64 efi/libefi efi/loader efi/loader/arch/amd64 efi/loader/arch/arm efi/loader/arch/arm64 i... Message-ID: <CAG6CVpX=yvW-CB0e8sbpr_AFG4YzynKJtYomPqjzjFBMjypb7Q@mail.gmail.com> In-Reply-To: <1452648737.46848.50.camel@freebsd.org> References: <201601120217.u0C2HdBC089684@repo.freebsd.org> <1452645668.46848.34.camel@freebsd.org> <56959DA7.9050206@freebsd.org> <1452646442.46848.37.camel@freebsd.org> <5695A5C4.9000409@multiplay.co.uk> <1452648737.46848.50.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 12, 2016 at 5:32 PM, Ian Lepore <ian@freebsd.org> wrote: > Yep, but then I had to do this because ef->off is 64 bits even on 32 > bit arches, so I got a pointer/int size mismatch warning... > > Index: common/load_elf.c > =================================================================== > --- common/load_elf.c (revision 293796) > +++ common/load_elf.c (working copy) > @@ -886,7 +886,7 @@ __elfN(parse_modmetadata)(struct preloaded_file *f > error = __elfN(reloc_ptr)(fp, ef, v, &md, sizeof(md)); > if (error == EOPNOTSUPP) { > md.md_cval += ef->off; > - md.md_data = (void *)((uintptr_t)md.md_data + ef->off); > + md.md_data = (void *)(uintptr_t)((uintptr_t)md.md_data + > ef->off); > } else if (error != 0) > return (error); > #endif > > > That is just some special kind of ugly. Yes. You could maybe do: md.md_data = (c_caddr_t)md.md_data + (ptrdiff_t)ef->off; Instead. Yes, the ptrdiff_t will truncate uint64_t on 32-bit pointer platforms, but the result is truncated regardless when it is stored in the md_data pointer. And the result under modulus is equivalent. (You could even change the type of md_data to c_caddr_t from 'const void *' to make it easier to do math on. Then this could just be: md.md_data += (ptrdiff_t)ef->off;) Best, Conrad
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpX=yvW-CB0e8sbpr_AFG4YzynKJtYomPqjzjFBMjypb7Q>