From owner-svn-src-head@FreeBSD.ORG Mon Sep 13 08:34:21 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 555BD1065670; Mon, 13 Sep 2010 08:34:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 145AA8FC0C; Mon, 13 Sep 2010 08:34:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8D8YKoA079018; Mon, 13 Sep 2010 08:34:20 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8D8YKTr079016; Mon, 13 Sep 2010 08:34:20 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201009130834.o8D8YKTr079016@svn.freebsd.org> From: Andriy Gapon Date: Mon, 13 Sep 2010 08:34:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212544 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2010 08:34:21 -0000 Author: avg Date: Mon Sep 13 08:34:20 2010 New Revision: 212544 URL: http://svn.freebsd.org/changeset/base/212544 Log: bus_add_child: add specialized default implementation that calls panic If a kobj method doesn't have any explicitly provided default implementation, then it is auto-assigned kobj_error_method. kobj_error_method is proper only for methods that return error code, because it just returns ENXIO. So, in the case of unimplemented bus_add_child caller would get (device_t)ENXIO as a return value, which would cause the mistake to go unnoticed, because return value is typically checked for NULL. Thus, a specialized null_add_child is added. It would have sufficied for correctness to return NULL, but this type of mistake was deemed to be rare and serious enough to call panic instead. Watch out for this kind of problem with other kobj methods. Suggested by: jhb, imp MFC after: 2 weeks Modified: head/sys/kern/bus_if.m Modified: head/sys/kern/bus_if.m ============================================================================== --- head/sys/kern/bus_if.m Mon Sep 13 07:29:02 2010 (r212543) +++ head/sys/kern/bus_if.m Mon Sep 13 08:34:20 2010 (r212544) @@ -26,6 +26,8 @@ # $FreeBSD$ # +#include +#include #include /** @@ -56,6 +58,14 @@ CODE { return (BUS_REMAP_INTR(dev, NULL, irq)); return (ENXIO); } + + static device_t + null_add_child(device_t bus, int order, const char *name, + int unit) + { + + panic("bus_add_child is not implemented"); + } }; /** @@ -203,7 +213,7 @@ METHOD device_t add_child { u_int _order; const char *_name; int _unit; -}; +} DEFAULT null_add_child; /** * @brief Allocate a system resource