Date: Sat, 7 Aug 2010 10:42:02 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no> Cc: hackers@freebsd.org Subject: Re: Why is TUNABLE_INT discouraged? Message-ID: <AANLkTikLXFH96-uXjU1-HoLceMs-sSW4VjACwHcOwoGj@mail.gmail.com> In-Reply-To: <86fwyq8rsc.fsf@ds4.des.no> References: <AANLkTinKaiGFhKRgqQ%2BFjm=02VfWCxULe0a68y-PkJx6@mail.gmail.com> <86fwyq8rsc.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
2010/8/7 Dag-Erling Sm=F8rgrav <des@des.no>: > Garrett Cooper <gcooper@FreeBSD.org> writes: >> =A0 =A0I found the commit where it was made (by des@ -- cvs revision >> 1.120), but unfortunately I lack the context as to why that suggestion >> is made; the commit isn't very explicit as to why integers tunables >> should be discouraged > > You're supposed to use TUNABLE_LONG or TUNABLE_ULONG instead. =A0From > digging in the -current archives, it seems that the motivation was a bug > that resulted from using a TUNABLE_INT for a value that was actually an > address. =A0It was doubly broken: first because it was too small on 64-bi= t > systems, and second because it was signed. Thanks for the explanation. I just found it interesting how the interfaces to [PCI BUS] resources, sysctls, and tunables are inconsistent in terms of what data types they support; resources only supports signed integers of various widths, sysctls support everything under the sun, and we know the story on tunables now. It's ok most of the time, but as we all know there are limits to the ranges for integers, and there's something a bit quirky about some of the code in sound(4) that I'm experimenting with to see whether or not it was there's an issue with bad casting, comparison, an uninitialized value, or another random race condition, that's wreaking havoc with my Audigy card every time I attach the driver as a module. Thanks! -Garrett
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikLXFH96-uXjU1-HoLceMs-sSW4VjACwHcOwoGj>