diff --git a/share/examples/kld/dyn_sysctl/dyn_sysctl.c b/share/examples/kld/dyn_sysctl/dyn_sysctl.c index bcef7d472c5e..75d351bef223 100644 --- a/share/examples/kld/dyn_sysctl/dyn_sysctl.c +++ b/share/examples/kld/dyn_sysctl/dyn_sysctl.c @@ -42,7 +42,7 @@ static struct sysctl_oid *a_root, *a_root1, *b_root; 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_ARGS) * 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 diff --git a/share/examples/kld/syscall/module/syscall.c b/share/examples/kld/syscall/module/syscall.c index 3416f3ca10a0..8d4f1fade0fe 100644 --- a/share/examples/kld/syscall/module/syscall.c +++ b/share/examples/kld/syscall/module/syscall.c @@ -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);