From owner-svn-src-all@FreeBSD.ORG Wed Jun 3 09:28:59 2009 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 92E931065672; Wed, 3 Jun 2009 09:28:59 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 622308FC14; Wed, 3 Jun 2009 09:28:59 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n539SxrP044750; Wed, 3 Jun 2009 09:28:59 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n539Sw6J044748; Wed, 3 Jun 2009 09:28:58 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <200906030928.n539Sw6J044748@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Wed, 3 Jun 2009 09:28:58 +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: r193374 - in head/share/examples/kld: dyn_sysctl syscall/module 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: Wed, 03 Jun 2009 09:29:00 -0000 Author: pjd Date: Wed Jun 3 09:28:58 2009 New Revision: 193374 URL: http://svn.freebsd.org/changeset/base/193374 Log: Where if not in examples we should follow style(9)? Modified: head/share/examples/kld/dyn_sysctl/dyn_sysctl.c head/share/examples/kld/syscall/module/syscall.c Modified: head/share/examples/kld/dyn_sysctl/dyn_sysctl.c ============================================================================== --- head/share/examples/kld/dyn_sysctl/dyn_sysctl.c Wed Jun 3 09:24:58 2009 (r193373) +++ head/share/examples/kld/dyn_sysctl/dyn_sysctl.c Wed Jun 3 09:28:58 2009 (r193374) @@ -42,7 +42,7 @@ static struct sysctl_oid *a_root, *a_roo static struct sysctl_ctx_list clist, clist1, clist2; static int -sysctl_dyn_sysctl_test (SYSCTL_HANDLER_ARGS) +sysctl_dyn_sysctl_test(SYSCTL_HANDLER_ARGS) { char *buf = "let's produce some text..."; @@ -53,7 +53,7 @@ sysctl_dyn_sysctl_test (SYSCTL_HANDLER_A * The function called at load/unload. */ static int -load (module_t mod, int cmd, void *arg) +load(module_t mod, int cmd, void *arg) { int error; @@ -78,37 +78,37 @@ load (module_t mod, int cmd, void *arg) SYSCTL_STATIC_CHILDREN(/* top of sysctl tree */), OID_AUTO, "dyn_sysctl", CTLFLAG_RW, 0, "dyn_sysctl root node"); - if(a_root == NULL) { + if (a_root == NULL) { printf("SYSCTL_ADD_NODE failed!\n"); return (EINVAL); } SYSCTL_ADD_LONG(&clist, SYSCTL_CHILDREN(a_root), - OID_AUTO, "long_a", CTLFLAG_RW, &a, "just to try"); + OID_AUTO, "long_a", CTLFLAG_RW, &a, "just to try"); SYSCTL_ADD_INT(&clist, SYSCTL_CHILDREN(a_root), - OID_AUTO, "int_b", CTLFLAG_RW, &b, 0, "just to try 1"); - a_root1=SYSCTL_ADD_NODE(&clist, SYSCTL_CHILDREN(a_root), - OID_AUTO, "nextlevel", CTLFLAG_RD, 0, "one level down"); + OID_AUTO, "int_b", CTLFLAG_RW, &b, 0, "just to try 1"); + a_root1 = SYSCTL_ADD_NODE(&clist, SYSCTL_CHILDREN(a_root), + OID_AUTO, "nextlevel", CTLFLAG_RD, 0, "one level down"); SYSCTL_ADD_STRING(&clist, SYSCTL_CHILDREN(a_root1), - OID_AUTO, "string_c", CTLFLAG_RD, c, 0, "just to try 2"); + OID_AUTO, "string_c", CTLFLAG_RD, c, 0, "just to try 2"); printf("1. (%p) / dyn_sysctl\n", &clist); /* Add a subtree under already existing category */ a_root1 = SYSCTL_ADD_NODE(&clist, SYSCTL_STATIC_CHILDREN(_kern), - OID_AUTO, "dyn_sysctl", CTLFLAG_RW, 0, "dyn_sysctl root node"); - if(a_root1 == NULL) { + OID_AUTO, "dyn_sysctl", CTLFLAG_RW, 0, "dyn_sysctl root node"); + if (a_root1 == NULL) { printf("SYSCTL_ADD_NODE failed!\n"); return (EINVAL); } SYSCTL_ADD_PROC(&clist, SYSCTL_CHILDREN(a_root1), - OID_AUTO, "procedure", CTLFLAG_RD, 0, 0, - sysctl_dyn_sysctl_test, "A", "I can be here, too"); + OID_AUTO, "procedure", CTLFLAG_RD, 0, 0, + sysctl_dyn_sysctl_test, "A", "I can be here, too"); printf(" (%p) /kern dyn_sysctl\n", &clist); /* Overlap second tree with the first. */ b_root = SYSCTL_ADD_NODE(&clist1, SYSCTL_CHILDREN(a_root), - OID_AUTO, "nextlevel", CTLFLAG_RD, 0, "one level down"); + OID_AUTO, "nextlevel", CTLFLAG_RD, 0, "one level down"); SYSCTL_ADD_STRING(&clist1, SYSCTL_CHILDREN(b_root), - OID_AUTO, "string_c1", CTLFLAG_RD, c, 0, "just to try 2"); + OID_AUTO, "string_c1", CTLFLAG_RD, c, 0, "just to try 2"); printf("2. (%p) / dyn_sysctl (overlapping #1)\n", &clist1); /* @@ -117,19 +117,19 @@ load (module_t mod, int cmd, void *arg) * WARNING: this is an example of WRONG use of dynamic sysctls. */ b_root=SYSCTL_ADD_NODE(&clist2, SYSCTL_CHILDREN(a_root1), - OID_AUTO, "bad", CTLFLAG_RW, 0, "dependent node"); + OID_AUTO, "bad", CTLFLAG_RW, 0, "dependent node"); SYSCTL_ADD_STRING(&clist2, SYSCTL_CHILDREN(b_root), - OID_AUTO, "string_c", CTLFLAG_RD, c, 0, "shouldn't panic"); + OID_AUTO, "string_c", CTLFLAG_RD, c, 0, "shouldn't panic"); printf("3. (%p) /kern/dyn_sysctl bad (WRONG!)\n", &clist2); break; case MOD_UNLOAD : printf("1. Try to free ctx1 (%p): ", &clist); - if(sysctl_ctx_free(&clist)) + if (sysctl_ctx_free(&clist) != 0) printf("failed: expected. Need to remove ctx3 first.\n"); else printf("HELP! sysctl_ctx_free(%p) succeeded. EXPECT PANIC!!!\n", &clist); printf("2. Try to free ctx3 (%p): ", &clist2); - if(sysctl_ctx_free(&clist2)) { + if (sysctl_ctx_free(&clist2) != 0) { printf("sysctl_ctx_free(%p) failed!\n", &clist2); /* Remove subtree forcefully... */ sysctl_remove_oid(b_root, 1, 1); @@ -137,7 +137,7 @@ load (module_t mod, int cmd, void *arg) } else printf("Ok\n"); printf("3. Try to free ctx1 (%p) again: ", &clist); - if(sysctl_ctx_free(&clist)) { + if (sysctl_ctx_free(&clist) != 0) { printf("sysctl_ctx_free(%p) failed!\n", &clist); /* Remove subtree forcefully... */ sysctl_remove_oid(a_root1, 1, 1); @@ -145,7 +145,7 @@ load (module_t mod, int cmd, void *arg) } else printf("Ok\n"); printf("4. Try to free ctx2 (%p): ", &clist1); - if(sysctl_ctx_free(&clist1)) { + if (sysctl_ctx_free(&clist1) != 0) { printf("sysctl_ctx_free(%p) failed!\n", &clist1); /* Remove subtree forcefully... */ sysctl_remove_oid(a_root, 1, 1); @@ -156,10 +156,10 @@ load (module_t mod, int cmd, void *arg) error = EOPNOTSUPP; break; } - return error; + return (error); } -static moduledata_t mod_data= { +static moduledata_t mod_data = { "dyn_sysctl", load, 0 Modified: head/share/examples/kld/syscall/module/syscall.c ============================================================================== --- head/share/examples/kld/syscall/module/syscall.c Wed Jun 3 09:24:58 2009 (r193373) +++ head/share/examples/kld/syscall/module/syscall.c Wed Jun 3 09:28:58 2009 (r193374) @@ -26,7 +26,6 @@ * $FreeBSD$ */ -#include #include #include #include @@ -38,18 +37,17 @@ /* * The function for implementing the syscall. */ - static int -hello (struct thread *td, void *arg) +hello(struct thread *td, void *arg) { - printf ("hello kernel\n"); - return 0; + + printf("hello kernel\n"); + return (0); } /* * The `sysent' for the new syscall */ - static struct sysent hello_sysent = { 0, /* sy_narg */ hello /* sy_call */ @@ -58,30 +56,28 @@ static struct sysent hello_sysent = { /* * The offset in sysent where the syscall is allocated. */ - static int offset = NO_SYSCALL; /* * The function called at load/unload. */ - static int -load (struct module *module, int cmd, void *arg) +load(struct module *module, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD : - printf ("syscall loaded at %d\n", offset); + printf("syscall loaded at %d\n", offset); break; case MOD_UNLOAD : - printf ("syscall unloaded from %d\n", offset); + printf("syscall unloaded from %d\n", offset); break; default : error = EOPNOTSUPP; break; } - return error; + return (error); } SYSCALL_MODULE(syscall, &offset, &hello_sysent, load, NULL);