diff options
author | glebius <glebius@FreeBSD.org> | 2013-07-17 12:28:48 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-07-17 12:28:48 +0000 |
commit | 331cbf7e38fd758b938c716f0a19ac7556724282 (patch) | |
tree | d43f3085eb62c7ff575faed53311f7227c936aef | |
parent | 48aa2f552b280366310de2f331df603dfa7cdff3 (diff) | |
download | FreeBSD-src-331cbf7e38fd758b938c716f0a19ac7556724282.zip FreeBSD-src-331cbf7e38fd758b938c716f0a19ac7556724282.tar.gz |
Improve example, so that it doesn't dump core when example module
isn't loaded.
-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 0051df5..23e4dc8 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); } |