Date: Wed, 02 Apr 2008 13:17:34 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: avg@icyb.net.ua Cc: freebsd-arch@freebsd.org Subject: Re: kobj method signature/prototype checking/enforcement Message-ID: <20080402.131734.255331081.imp@bsdimp.com> In-Reply-To: <47F347B1.2020509@icyb.net.ua> References: <47F347B1.2020509@icyb.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <47F347B1.2020509@icyb.net.ua> Andriy Gapon <avg@icyb.net.ua> writes: : I propose to defend against this problem using the following macro for : KOBJMETHOD: : #define KOBJMETHOD(NAME, FUNC) \ : { &NAME##_desc, (kobjop_t) (FUNC != (NAME##_t *)NULL ? FUNC : NULL) } ... : Here's a general overview of issues discovered: : 1. integer parameters differing in signedness (totally harmless, I think) : 2. using void return type instead of int, usually for device_shutdown : method (not sure about this one) : 3. using int return type instead of specific size integer return type, : typically for sound channel interface methods : 4. 'char *' parameter instead of 'const char *' parameter (potentially : can result in future problems) : 5. significantly different signatures for several "dummy" methods that : do not actually use any of the parameters and simply print a message or : panic. : : While the above issues are quite harmless, I still think that adding : such a checking code is a good thing. It will help with new code : development and it will help general code quality and maintenance. : : Unfortunately I don't have my FreeBSD development environment quite set : up (yet) for large scale development, so at this point I can not provide : a patch for HEAD that would fix all the build breakages (on all the : platforms) that would be caused by the proposed change (when -Werror is : in effect). Yes! I think I like this approach, and would like to see it fleshed out more. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080402.131734.255331081.imp>