From owner-freebsd-arch@FreeBSD.ORG Wed Apr 2 19:21:02 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3947E1065674 for ; Wed, 2 Apr 2008 19:21:02 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id C9EC38FC38 for ; Wed, 2 Apr 2008 19:21:01 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m32JGiYO015549; Wed, 2 Apr 2008 13:16:45 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 02 Apr 2008 13:17:34 -0600 (MDT) Message-Id: <20080402.131734.255331081.imp@bsdimp.com> To: avg@icyb.net.ua From: "M. Warner Losh" In-Reply-To: <47F347B1.2020509@icyb.net.ua> References: <47F347B1.2020509@icyb.net.ua> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: kobj method signature/prototype checking/enforcement X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Apr 2008 19:21:02 -0000 In message: <47F347B1.2020509@icyb.net.ua> Andriy Gapon 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