Date: Mon, 19 Feb 2018 14:19:53 +0800 From: Julian Elischer <julian@freebsd.org> To: Kyle Evans <kevans91@ksu.edu>, Eitan Adler <lists@eitanadler.com> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: 1 << 31 redux Message-ID: <798b566c-dc9c-cdd8-9040-6fa0806c1406@freebsd.org> In-Reply-To: <CACNAnaF-PiiG5nfOqc=zXwrHj%2BMs94SfWAaoF_VP8agz1CXLxA@mail.gmail.com> References: <CAF6rxg=GbfpBfPAAJg0RvpMrWW8p%2B0Ayf_Zd9i7Em2kOijFCjA@mail.gmail.com> <CACNAnaF-PiiG5nfOqc=zXwrHj%2BMs94SfWAaoF_VP8agz1CXLxA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 14/1/18 1:34 am, Kyle Evans wrote: > On Thu, Jan 11, 2018 at 6:03 AM, Eitan Adler <lists@eitanadler.com> wrote: >> Hi all, >> >> A few years ago I fixed most of the cases where we used 1 << 31 in FreeBSD. >> This expression is illegal in C. Since then the issue has arisen again. >> >> https://reviews.freebsd.org/D13858 fixed most of the non-contrib cases. >> >> I'd also like to see if we could find some more general solution, be it a >> compiler warning, bit set macro, or otherwise. >> > For what it's worth, I've really come to like and appreciate NetBSD's > approach with __BIT/__BITS. See [1] for implementation, [2] for usage. > > [1] http://src.illumos.org/source/xref/netbsd-src/sys/sys/cdefs.h#577 I like __BIT() but it should give a compile error if the number is too large rather than just setting it to 0. in fact I think I think it should take a target and use the size of the target rather than assuming int. > [2] http://src.illumos.org/source/xref/netbsd-src/sys/arch/arm/sunxi/sunxi_usbphy.c#L44 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?798b566c-dc9c-cdd8-9040-6fa0806c1406>