Author: kib
Date: Tue Jul  3 08:46:26 2012
New Revision: 238064
URL: http://svn.freebsd.org/changeset/base/238064

Log:
  MFC r237844, r237845, r237846:
  Minor tweaks.

Modified:
  stable/8/usr.bin/killall/killall.c
Directory Properties:
  stable/8/usr.bin/killall/   (props changed)

Modified: stable/8/usr.bin/killall/killall.c
==============================================================================
--- stable/8/usr.bin/killall/killall.c  Tue Jul  3 08:42:48 2012        
(r238063)
+++ stable/8/usr.bin/killall/killall.c  Tue Jul  3 08:46:26 2012        
(r238064)
@@ -102,7 +102,7 @@ nosig(char *name)
 int
 main(int ac, char **av)
 {
-       struct kinfo_proc *procs = NULL, *newprocs;
+       struct kinfo_proc *procs, *newprocs;
        struct stat     sb;
        struct passwd   *pw;
        regex_t         rgx;
@@ -285,9 +285,6 @@ main(int ac, char **av)
        size = 0;
        mib[0] = CTL_KERN;
        mib[1] = KERN_PROC;
-       mib[2] = KERN_PROC_PROC;
-       mib[3] = 0;
-       miblen = 3;
 
        if (user) {
                mib[2] = eflag ? KERN_PROC_UID : KERN_PROC_RUID;
@@ -297,16 +294,20 @@ main(int ac, char **av)
                mib[2] = KERN_PROC_TTY;
                mib[3] = tdev;
                miblen = 4;
+       } else {
+               mib[2] = KERN_PROC_PROC;
+               mib[3] = 0;
+               miblen = 3;
        }
 
+       procs = NULL;
        st = sysctl(mib, miblen, NULL, &size, NULL, 0);
        do {
                size += size / 10;
                newprocs = realloc(procs, size);
-               if (newprocs == 0) {
-                       if (procs)
-                               free(procs);
-                       errx(1, "could not reallocate memory");
+               if (newprocs == NULL) {
+                       free(procs);
+                       err(1, "could not reallocate memory");
                }
                procs = newprocs;
                st = sysctl(mib, miblen, procs, &size, NULL, 0);
@@ -316,7 +317,7 @@ main(int ac, char **av)
        if (size % sizeof(struct kinfo_proc) != 0) {
                fprintf(stderr, "proc size mismatch (%zu total, %zu chunks)\n",
                        size, sizeof(struct kinfo_proc));
-               fprintf(stderr, "userland out of sync with kernel, recompile 
libkvm etc\n");
+               fprintf(stderr, "userland out of sync with kernel\n");
                exit(1);
        }
        nprocs = size / sizeof(struct kinfo_proc);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to