diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1998-06-29 22:27:47 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1998-06-29 22:27:47 +0000 |
commit | 0180b7cbd981e2513e9e516090fb698b822e5fbb (patch) | |
tree | eb3a055009a014cb54a4007d12c3931d32499677 /lib | |
parent | 2b940e0d84eaaf8b0bea21e90cfc71776f226352 (diff) |
Do the right thing with error return values.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libkvm.old/kvm.c | 16 | ||||
-rw-r--r-- | lib/libkvm/kvm.c | 22 |
2 files changed, 19 insertions, 19 deletions
diff --git a/lib/libkvm.old/kvm.c b/lib/libkvm.old/kvm.c index 6977399e1d1..95037b1c057 100644 --- a/lib/libkvm.old/kvm.c +++ b/lib/libkvm.old/kvm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm.c,v 1.4 1997/07/25 20:30:26 mickey Exp $ */ +/* $OpenBSD: kvm.c,v 1.5 1998/06/29 22:27:46 angelos Exp $ */ /* $NetBSD: kvm.c,v 1.2 1996/05/13 02:30:22 thorpej Exp $ */ @@ -287,7 +287,7 @@ kvm_openfiles(uf, mf, sf, flag, errout) if ((kd = malloc(sizeof(*kd))) == NULL) { (void)strcpy(errout, strerror(errno)); - return (0); + return (-1); } kd->program = 0; return (_kvm_open(kd, uf, mf, sf, flag, errout)); @@ -305,7 +305,7 @@ kvm_open(uf, mf, sf, flag, program) if ((kd = malloc(sizeof(*kd))) == NULL && program != NULL) { (void)fprintf(stderr, "%s: %s\n", strerror(errno)); - return (0); + return (-1); } kd->program = program; return (_kvm_open(kd, uf, mf, sf, flag, NULL)); @@ -480,12 +480,12 @@ kvm_read(kd, kva, buf, len) errno = 0; if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) { _kvm_err(kd, 0, "invalid address (%x)", kva); - return (0); + return (-1); } cc = read(kd->vmfd, buf, len); if (cc < 0) { _kvm_syserr(kd, 0, "kvm_read"); - return (0); + return (-1); } else if (cc < len) _kvm_err(kd, kd->program, "short read"); return (cc); @@ -542,19 +542,19 @@ kvm_write(kd, kva, buf, len) errno = 0; if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) { _kvm_err(kd, 0, "invalid address (%x)", kva); - return (0); + return (-1); } cc = write(kd->vmfd, buf, len); if (cc < 0) { _kvm_syserr(kd, 0, "kvm_write"); - return (0); + return (-1); } else if (cc < len) _kvm_err(kd, kd->program, "short write"); return (cc); } else { _kvm_err(kd, kd->program, "kvm_write not implemented for dead kernels"); - return (0); + return (-1); } /* NOTREACHED */ } diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index 9721dd589bf..314f9dfd499 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm.c,v 1.10 1997/07/25 20:30:17 mickey Exp $ */ +/* $OpenBSD: kvm.c,v 1.11 1998/06/29 22:27:05 angelos Exp $ */ /* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */ /*- @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94"; #else -static char *rcsid = "$OpenBSD: kvm.c,v 1.10 1997/07/25 20:30:17 mickey Exp $"; +static char *rcsid = "$OpenBSD: kvm.c,v 1.11 1998/06/29 22:27:05 angelos Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -475,7 +475,7 @@ off_t dump_off; if ((CORE_GETMAGIC(cpu_hdr) != KCORE_MAGIC) || (CORE_GETMID(cpu_hdr) != MID_MACHINE)) { _kvm_err(kd, 0, "invalid magic in cpu_hdr"); - return (0); + return (-1); } hdr_size = ALIGN(sizeof(cpu_hdr)); @@ -639,7 +639,7 @@ kvm_openfiles(uf, mf, sf, flag, errout) if ((kd = malloc(sizeof(*kd))) == NULL) { (void)strncpy(errout, strerror(errno), _POSIX2_LINE_MAX - 1); - return (0); + return (-1); } kd->program = 0; return (_kvm_open(kd, uf, mf, sf, flag, errout)); @@ -657,7 +657,7 @@ kvm_open(uf, mf, sf, flag, program) if ((kd = malloc(sizeof(*kd))) == NULL && program != NULL) { (void)fprintf(stderr, "%s: %s\n", strerror(errno)); - return (0); + return (-1); } kd->program = program; return (_kvm_open(kd, uf, mf, sf, flag, NULL)); @@ -875,19 +875,19 @@ kvm_read(kd, kva, buf, len) if (lseek(kd->vmfd, (off_t)kva, SEEK_SET) == -1 && errno != 0) { _kvm_err(kd, 0, "invalid address (%lx)", kva); - return (0); + return (-1); } cc = read(kd->vmfd, buf, len); if (cc < 0) { _kvm_syserr(kd, 0, "kvm_read"); - return (0); + return (-1); } else if (cc < len) _kvm_err(kd, kd->program, "short read"); return (cc); } else { if ((kd->kcore_hdr == NULL) || (kd->cpu_data == NULL)) { _kvm_err(kd, kd->program, "no valid dump header"); - return (0); + return (-1); } cp = buf; while (len > 0) { @@ -945,19 +945,19 @@ kvm_write(kd, kva, buf, len) if (lseek(kd->vmfd, (off_t)kva, SEEK_SET) == -1 && errno != 0) { _kvm_err(kd, 0, "invalid address (%lx)", kva); - return (0); + return (-1); } cc = write(kd->vmfd, buf, len); if (cc < 0) { _kvm_syserr(kd, 0, "kvm_write"); - return (0); + return (-1); } else if (cc < len) _kvm_err(kd, kd->program, "short write"); return (cc); } else { _kvm_err(kd, kd->program, "kvm_write not implemented for dead kernels"); - return (0); + return (-1); } /* NOTREACHED */ } |