Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/nbperf GCC's propolice complains about dynamic stack...



details:   https://anonhg.NetBSD.org/src/rev/e40a6a414813
branches:  trunk
changeset: 746890:e40a6a414813
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Aug 22 17:52:17 2009 +0000

description:
GCC's propolice complains about dynamic stack arrays to bite the bullet
and introduce a compile constant that limits the number of hash results.
Verify that the choosen hash function is not beyond that limit and just
the upper limit as static size in the graph tree functions.

diffstat:

 usr.bin/nbperf/graph2.c |  6 +++---
 usr.bin/nbperf/graph3.c |  6 +++---
 usr.bin/nbperf/nbperf.c |  6 ++++--
 usr.bin/nbperf/nbperf.h |  4 +++-
 4 files changed, 13 insertions(+), 9 deletions(-)

diffs (99 lines):

diff -r 77f339a26d00 -r e40a6a414813 usr.bin/nbperf/graph2.c
--- a/usr.bin/nbperf/graph2.c   Sat Aug 22 17:38:06 2009 +0000
+++ b/usr.bin/nbperf/graph2.c   Sat Aug 22 17:52:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: graph2.c,v 1.1 2009/08/15 16:21:04 joerg Exp $ */
+/*     $NetBSD: graph2.c,v 1.2 2009/08/22 17:52:17 joerg Exp $ */
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: graph2.c,v 1.1 2009/08/15 16:21:04 joerg Exp $");
+__RCSID("$NetBSD: graph2.c,v 1.2 2009/08/22 17:52:17 joerg Exp $");
 
 #include <err.h>
 #include <inttypes.h>
@@ -75,7 +75,7 @@
 graph2_hash(struct nbperf *nbperf, struct graph2 *graph)
 {
        struct vertex2 *v;
-       uint32_t hashes[nbperf->hash_size];
+       uint32_t hashes[NBPERF_MAX_HASH_SIZE];
        size_t i;
 
        for (i = 0; i < graph->e; ++i) {
diff -r 77f339a26d00 -r e40a6a414813 usr.bin/nbperf/graph3.c
--- a/usr.bin/nbperf/graph3.c   Sat Aug 22 17:38:06 2009 +0000
+++ b/usr.bin/nbperf/graph3.c   Sat Aug 22 17:52:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: graph3.c,v 1.1 2009/08/15 16:21:05 joerg Exp $ */
+/*     $NetBSD: graph3.c,v 1.2 2009/08/22 17:52:17 joerg Exp $ */
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: graph3.c,v 1.1 2009/08/15 16:21:05 joerg Exp $");
+__RCSID("$NetBSD: graph3.c,v 1.2 2009/08/22 17:52:17 joerg Exp $");
 
 #include <err.h>
 #include <inttypes.h>
@@ -75,7 +75,7 @@
 graph3_hash(struct nbperf *nbperf, struct graph3 *graph)
 {
        struct vertex3 *v;
-       uint32_t hashes[nbperf->hash_size];
+       uint32_t hashes[NBPERF_MAX_HASH_SIZE];
        size_t i;
 
        for (i = 0; i < graph->e; ++i) {
diff -r 77f339a26d00 -r e40a6a414813 usr.bin/nbperf/nbperf.c
--- a/usr.bin/nbperf/nbperf.c   Sat Aug 22 17:38:06 2009 +0000
+++ b/usr.bin/nbperf/nbperf.c   Sat Aug 22 17:52:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nbperf.c,v 1.1 2009/08/15 16:21:05 joerg Exp $ */
+/*     $NetBSD: nbperf.c,v 1.2 2009/08/22 17:52:17 joerg Exp $ */
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: nbperf.c,v 1.1 2009/08/15 16:21:05 joerg Exp $");
+__RCSID("$NetBSD: nbperf.c,v 1.2 2009/08/22 17:52:17 joerg Exp $");
 
 #include <sys/endian.h>
 #include <err.h>
@@ -87,6 +87,8 @@
                nbperf->print_hash = mi_vector_hash_print_hash;
                return;
        }
+       if (nbperf->hash_size > NBPERF_MAX_HASH_SIZE)
+               errx(1, "Hash function creates too many output values");
        errx(1, "Unknown hash function: %s", arg);
 }
 
diff -r 77f339a26d00 -r e40a6a414813 usr.bin/nbperf/nbperf.h
--- a/usr.bin/nbperf/nbperf.h   Sat Aug 22 17:38:06 2009 +0000
+++ b/usr.bin/nbperf/nbperf.h   Sat Aug 22 17:52:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nbperf.h,v 1.1 2009/08/15 16:21:05 joerg Exp $ */
+/*     $NetBSD: nbperf.h,v 1.2 2009/08/22 17:52:17 joerg Exp $ */
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,6 +31,8 @@
  * SUCH DAMAGE.
  */
 
+#define        NBPERF_MAX_HASH_SIZE    3
+
 struct nbperf {
        FILE *output;
        FILE *map_output;



Home | Main Index | Thread Index | Old Index