From owner-svn-src-all@FreeBSD.ORG Tue Dec 21 18:23:04 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48D29106564A; Tue, 21 Dec 2010 18:23:04 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 37B5F8FC12; Tue, 21 Dec 2010 18:23:04 +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 oBLIN4nf072185; Tue, 21 Dec 2010 18:23:04 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBLIN4uk072182; Tue, 21 Dec 2010 18:23:04 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201012211823.oBLIN4uk072182@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 21 Dec 2010 18:23:04 +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: r216620 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Dec 2010 18:23:04 -0000 Author: mdf Date: Tue Dec 21 18:23:03 2010 New Revision: 216620 URL: http://svn.freebsd.org/changeset/base/216620 Log: Initialize fp_location for explicitly managed fail points, and push the parentheses around the location for simple fail points into the location string. This makes the print on fail point set more consistent between the two versions. Also fix up fail.h a little for style(9): only use one of sys/param.h and sys/types.h, and use the existing __XSTRING() macro instead of rolling our own. Also fix up a few tabs on changed and nearby lines. Lastly, since KFAIL_POINT_{BEGIN,END} are not meant for use outside this file, just eliminate the macros entirely. MFC after: 1 week Modified: head/sys/kern/kern_fail.c head/sys/sys/fail.h Modified: head/sys/kern/kern_fail.c ============================================================================== --- head/sys/kern/kern_fail.c Tue Dec 21 17:24:32 2010 (r216619) +++ head/sys/kern/kern_fail.c Tue Dec 21 18:23:03 2010 (r216620) @@ -177,6 +177,7 @@ fail_point_init(struct fail_point *fp, c va_end(ap); } fp->fp_name = name; + fp->fp_location = ""; fp->fp_flags |= FAIL_POINT_DYNAMIC_NAME; fp->fp_sleep_fn = NULL; fp->fp_sleep_arg = NULL; @@ -372,10 +373,10 @@ fail_point_set(struct fail_point *fp, ch end: #ifdef IWARNING if (error) - IWARNING("Failed to set %s (%s) to %s", + IWARNING("Failed to set %s %s to %s", fp->fp_name, fp->fp_location, buf); else - INOTICE("Set %s (%s) to %s", + INOTICE("Set %s %s to %s", fp->fp_name, fp->fp_location, buf); #endif /* IWARNING */ Modified: head/sys/sys/fail.h ============================================================================== --- head/sys/sys/fail.h Tue Dec 21 17:24:32 2010 (r216619) +++ head/sys/sys/fail.h Tue Dec 21 18:23:03 2010 (r216620) @@ -32,10 +32,9 @@ #ifndef _SYS_FAIL_H_ #define _SYS_FAIL_H_ -#include - -#include #include +#include +#include #include #include @@ -129,10 +128,8 @@ fail_point_eval(struct fail_point *fp, i __END_DECLS /* Declare a fail_point and its sysctl in a function. */ -#define _FAIL_POINT_NAME(name) _fail_point_##name -#define _STRINGIFY_HELPER(x) #x -#define _STRINGIFY(x) _STRINGIFY_HELPER(x) -#define _FAIL_POINT_LOCATION() __FILE__ ":" _STRINGIFY(__LINE__) +#define _FAIL_POINT_NAME(name) _fail_point_##name +#define _FAIL_POINT_LOCATION() "(" __FILE__ ":" __XSTRING(__LINE__) ")" /** * Instantiate a failpoint which returns "value" from the function when triggered. @@ -178,53 +175,43 @@ __END_DECLS /** * Instantiate a failpoint which runs arbitrary code when triggered. * @param parent The parent sysctl under which to locate the sysctl - * @param name The name of the failpoint in the sysctl tree (and printouts) + * @param name The name of the failpoint in the sysctl tree + * (and printouts) * @param code The arbitrary code to run when triggered. Can reference - * "RETURN_VALUE" if desired to extract the specified user - * return-value when triggered + * "RETURN_VALUE" if desired to extract the specified + * user return-value when triggered. Note that this is + * implemented with a do-while loop so be careful of + * break and continue statements. */ #define KFAIL_POINT_CODE(parent, name, code) \ - KFAIL_POINT_START(parent, name) { \ +do { \ + int RETURN_VALUE; \ + static struct fail_point _FAIL_POINT_NAME(name) = { \ + #name, \ + _FAIL_POINT_LOCATION(), \ + TAILQ_HEAD_INITIALIZER(_FAIL_POINT_NAME(name).fp_entries), \ + 0, \ + NULL, NULL, \ + }; \ + SYSCTL_OID(parent, OID_AUTO, name, \ + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ + &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ + "A", ""); \ + \ + if (__predict_false( \ + fail_point_eval(&_FAIL_POINT_NAME(name), &RETURN_VALUE))) { \ + \ code; \ - } FAIL_POINT_END + \ + } \ +} while (0) + /** * @} * (end group failpoint) */ -/** - * Internal macro to implement above #defines -- should not be used directly. - * @ingroup failpoint_private - */ -#define KFAIL_POINT_START(parent, name) \ - do { \ - int RETURN_VALUE; \ - static struct fail_point _FAIL_POINT_NAME(name) = { \ - #name, \ - _FAIL_POINT_LOCATION(), \ - TAILQ_HEAD_INITIALIZER( \ - _FAIL_POINT_NAME(name).fp_entries), \ - 0, \ - NULL, NULL, \ - }; \ - SYSCTL_OID(parent, OID_AUTO, name, \ - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ - &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ - "A", ""); \ - \ - if (__predict_false( \ - fail_point_eval(&_FAIL_POINT_NAME(name), \ - &RETURN_VALUE))) { - -/** - * Internal macro to implement above #defines -- should not be used directly. - * @ingroup failpoint_private - */ -#define FAIL_POINT_END \ - } \ - } while (0) - #ifdef _KERNEL int fail_point_sysctl(SYSCTL_HANDLER_ARGS);