Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/pmap Move getuid() out of the loop, uid should not c...
details: https://anonhg.NetBSD.org/src/rev/96de1750fae7
branches: trunk
changeset: 770624:96de1750fae7
user: jym <jym%NetBSD.org@localhost>
date: Tue Oct 25 23:45:19 2011 +0000
description:
Move getuid() out of the loop, uid should not change behind our back. KNF.
diffstat:
usr.bin/pmap/main.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (54 lines):
diff -r 9796bdaed68c -r 96de1750fae7 usr.bin/pmap/main.c
--- a/usr.bin/pmap/main.c Tue Oct 25 23:13:56 2011 +0000
+++ b/usr.bin/pmap/main.c Tue Oct 25 23:45:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $ */
+/* $NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $ */
/*
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $");
+__RCSID("$NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $");
#endif
#include <sys/param.h>
@@ -289,6 +289,8 @@
exit(0);
}
+ uid = getuid();
+
do {
if (pid == -1) {
if (argc == 0)
@@ -309,8 +311,6 @@
}
}
- uid = getuid();
-
errno = 0;
/* find the process id */
if (pid == 0) {
@@ -321,7 +321,7 @@
}
} else {
kproc = kvm_getproc2(kd, KERN_PROC_PID, pid,
- sizeof(struct kinfo_proc2), &rc);
+ sizeof(struct kinfo_proc2), &rc);
if (kproc == NULL || rc == 0) {
errno = ESRCH;
} else if (uid != 0 && uid != kproc->p_uid) {
@@ -341,7 +341,7 @@
/* dump it */
if (many) {
- if (kproc)
+ if (kproc != NULL)
printf("process %d:\n", kproc->p_pid);
else
printf("kernel:\n");
Home |
Main Index |
Thread Index |
Old Index