Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pstat Use the array of dtype names instead of hand-...



details:   https://anonhg.NetBSD.org/src/rev/9d350c55114f
branches:  trunk
changeset: 572100:9d350c55114f
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Dec 18 08:43:35 2004 +0000

description:
Use the array of dtype names instead of hand-rolling our own.

diffstat:

 usr.sbin/pstat/pstat.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r 46575c17a457 -r 9d350c55114f usr.sbin/pstat/pstat.c
--- a/usr.sbin/pstat/pstat.c    Sat Dec 18 08:43:08 2004 +0000
+++ b/usr.sbin/pstat/pstat.c    Sat Dec 18 08:43:35 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pstat.c,v 1.87 2004/12/09 01:14:59 matt Exp $  */
+/*     $NetBSD: pstat.c,v 1.88 2004/12/18 08:43:35 christos Exp $      */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)pstat.c    8.16 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: pstat.c,v 1.87 2004/12/09 01:14:59 matt Exp $");
+__RCSID("$NetBSD: pstat.c,v 1.88 2004/12/18 08:43:35 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -106,6 +106,9 @@
 char   *memf   = NULL;
 kvm_t  *kd;
 
+static const char * const dtypes[] = { DTYPE_NAMES };
+
+
 static const struct {
        u_int m_flag;
        u_int m_visible;
@@ -880,8 +883,6 @@
        char flags[sizeof(filemode_flags) / sizeof(filemode_flags[0])];
        char *buf, *offset;
        int len, maxfile, nfile, ovflw;
-       static const char * const dtypes[] =
-               { "???", "inode", "socket", "pipe" };
 
        KGET(FNL_MAXFILE, maxfile);
        if (totalflag) {
@@ -905,7 +906,7 @@
            (PTRSTRWIDTH - 4) / 2, "", " LOC", (PTRSTRWIDTH - 4) / 2, "",
            (PTRSTRWIDTH - 4) / 2, "", "DATA", (PTRSTRWIDTH - 4) / 2, "");
        for (; (char *)fp < offset + len; addr = fp->f_list.le_next, fp++) {
-               if ((unsigned)fp->f_type > DTYPE_PIPE)
+               if ((unsigned)fp->f_type > sizeof(dtypes) / sizeof(dtypes[0]))
                        continue;
                ovflw = 0;
                (void)getflags(filemode_flags, flags, fp->f_flag);



Home | Main Index | Thread Index | Old Index