Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jul 2013 12:28:49 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r253420 - head/share/examples/kld/syscall/test
Message-ID:  <201307171228.r6HCSnng075338@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Wed Jul 17 12:28:48 2013
New Revision: 253420
URL: http://svnweb.freebsd.org/changeset/base/253420

Log:
  Improve example, so that it doesn't dump core when example module
  isn't loaded.

Modified:
  head/share/examples/kld/syscall/test/call.c

Modified: head/share/examples/kld/syscall/test/call.c
==============================================================================
--- head/share/examples/kld/syscall/test/call.c	Wed Jul 17 11:51:24 2013	(r253419)
+++ head/share/examples/kld/syscall/test/call.c	Wed Jul 17 12:28:48 2013	(r253420)
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307171228.r6HCSnng075338>