diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2013-07-17 12:28:48 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2013-07-17 12:28:48 +0000 |
commit | 9fd7a1b3ddb0f52b89ae368fe2d126677fad49e9 (patch) | |
tree | d43f3085eb62c7ff575faed53311f7227c936aef /share/examples/kld/syscall/test | |
parent | b13ce70710bdc0791e561dbbbc1045383f40b61a (diff) |
Improve example, so that it doesn't dump core when example module
isn't loaded.
Notes
Notes:
svn path=/head/; revision=253420
Diffstat (limited to 'share/examples/kld/syscall/test')
-rw-r--r-- | share/examples/kld/syscall/test/call.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/share/examples/kld/syscall/test/call.c b/share/examples/kld/syscall/test/call.c index 0051df5b106c..23e4dc8dcc62 100644 --- a/share/examples/kld/syscall/test/call.c +++ b/share/examples/kld/syscall/test/call.c @@ -30,6 +30,7 @@ #include <sys/module.h> #include <sys/syscall.h> +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -37,11 +38,14 @@ int main(int argc __unused, char **argv __unused) { - int syscall_num; + int modid, syscall_num; struct module_stat stat; stat.version = sizeof(stat); - modstat(modfind("sys/syscall"), &stat); + if ((modid = modfind("sys/syscall")) == -1) + err(1, "modfind"); + if (modstat(modid, &stat) != 0) + err(1, "mostat"); syscall_num = stat.data.intval; return syscall (syscall_num); } |