Source-Changes-HG archive

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

[src/netbsd-3]: src/usr.bin/pmc Pull up revision 1.12 (requested by lukem in ...



details:   https://anonhg.NetBSD.org/src/rev/2bf08b5f79da
branches:  netbsd-3
changeset: 576226:2bf08b5f79da
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Jun 15 05:14:13 2005 +0000

description:
Pull up revision 1.12 (requested by lukem in ticket #406):
Improve argument error checking.
Detected with -Wuninitialized.

diffstat:

 usr.bin/pmc/pmc.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r 21e9e4c0ee05 -r 2bf08b5f79da usr.bin/pmc/pmc.c
--- a/usr.bin/pmc/pmc.c Wed Jun 15 05:10:35 2005 +0000
+++ b/usr.bin/pmc/pmc.c Wed Jun 15 05:14:13 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmc.c,v 1.11 2004/01/05 23:23:36 jmmv Exp $    */
+/*     $NetBSD: pmc.c,v 1.11.6.1 2005/06/15 05:14:13 snj Exp $ */
 
 /*
  * Copyright 2000 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: pmc.c,v 1.11 2004/01/05 23:23:36 jmmv Exp $");
+__RCSID("$NetBSD: pmc.c,v 1.11.6.1 2005/06/15 05:14:13 snj Exp $");
 #endif
 
 #include <sys/types.h>
@@ -384,7 +384,7 @@
 main(int argc, char **argv)
 {
        int c, status, ret0, ret1, errn0, errn1;
-       char *event;
+       char *event = NULL;
        const struct pmc_name2val_cpus *pncp;
        const struct pmc_name2val *pnp;
        struct i386_pmc_info_args pi;
@@ -392,6 +392,8 @@
        struct i386_pmc_read_args pr0, pr1;
        pid_t pid;
 
+       errn0 = errn1 = 0;
+
        if (i386_pmc_info(&pi) < 0)
                errx(2, "PMC support is not compiled into the kernel");
 
@@ -421,16 +423,16 @@
                        pnp = find_pmc_name(pncp, event);
                        break;
                case 'h':
-                       if (argc == 2) {
-                               list_pmc_names(pncp);
-                               exit(0);
-                       }
+                       if (argc != 2)
+                               usage();
+                       list_pmc_names(pncp);
+                       exit(0);
                default:
                        usage();
                }
        }
 
-       if (pnp == NULL || argc <= optind)
+       if (pnp == NULL || argc <= optind || event == NULL)
                usage();
 
        memset(&pss0, 0, sizeof pss0);



Home | Main Index | Thread Index | Old Index