summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1994-11-14 07:54:06 +0000
committerbde <bde@FreeBSD.org>1994-11-14 07:54:06 +0000
commita5b37c90d585fe584f03989306738bfa7c295c5f (patch)
tree59e8b85597b788fa68f4efb783e425793a839469 /usr.sbin
parent3c1db6da25d8fb80057a3727acf12d8752b32d09 (diff)
downloadFreeBSD-src-a5b37c90d585fe584f03989306738bfa7c295c5f.zip
FreeBSD-src-a5b37c90d585fe584f03989306738bfa7c295c5f.tar.gz
Don't follow a null pointer for the reporting error if kvm_openfiles() fails.
Don't ever pretend that the program is named "." and has no args.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/swapinfo/swapinfo.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/usr.sbin/swapinfo/swapinfo.c b/usr.sbin/swapinfo/swapinfo.c
index 7a8d12c..811a936 100644
--- a/usr.sbin/swapinfo/swapinfo.c
+++ b/usr.sbin/swapinfo/swapinfo.c
@@ -16,6 +16,7 @@
#include <sys/rlist.h>
#include <nlist.h>
#include <kvm.h>
+#include <limits.h>
struct rlist *swaplist;
@@ -45,12 +46,11 @@ char **argv;
static long blocksize;
static int headerlen;
static char *header;
- char **save;
kvm_t *kd;
+ char errbuf[_POSIX2_LINE_MAX];
/* We are trying to be simple here: */
- save = argv;
while ((ch = getopt(argc, argv, "k")) != EOF)
switch(ch) {
case 'k':
@@ -60,19 +60,13 @@ char **argv;
default:
usage();
}
- argv += optind;
-
- if (!*argv) {
- argv = save;
- argv[0] = ".";
- argv[1] = NULL;
- }
/* Open up /dev/kmem for reading. */
-
- if ((kd = kvm_openfiles(NULL, NULL, NULL, NULL, NULL)) == (kvm_t *)0) {
- fprintf (stderr, "%s: kvm_openfiles: %s\n",
- argv [0], kvm_geterr(kd));
+
+ kd = kvm_openfiles((char *)NULL, (char *)NULL, (char *)NULL, 0, errbuf);
+ if (kd == NULL) {
+ fprintf (stderr, "%s: kvm_openfiles: %s\n",
+ argv [0], errbuf);
exit (1);
}
OpenPOWER on IntegriCloud