kobj method signature/prototype checking/enforcement

M. Warner Losh imp at bsdimp.com
Wed Apr 2 12:21:02 PDT 2008


In message: <47F347B1.2020509 at icyb.net.ua>
            Andriy Gapon <avg at 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


More information about the freebsd-arch mailing list