Module Name: src
Committed By: joerg
Date: Sat Aug 22 17:52:18 UTC 2009
Modified Files:
src/usr.bin/nbperf: graph2.c graph3.c nbperf.c nbperf.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/nbperf/graph2.c \
src/usr.bin/nbperf/graph3.c src/usr.bin/nbperf/nbperf.c \
src/usr.bin/nbperf/nbperf.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/nbperf/graph2.c
diff -u src/usr.bin/nbperf/graph2.c:1.1 src/usr.bin/nbperf/graph2.c:1.2
--- src/usr.bin/nbperf/graph2.c:1.1 Sat Aug 15 16:21:04 2009
+++ src/usr.bin/nbperf/graph2.c Sat Aug 22 17:52:17 2009
@@ -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) {
Index: src/usr.bin/nbperf/graph3.c
diff -u src/usr.bin/nbperf/graph3.c:1.1 src/usr.bin/nbperf/graph3.c:1.2
--- src/usr.bin/nbperf/graph3.c:1.1 Sat Aug 15 16:21:05 2009
+++ src/usr.bin/nbperf/graph3.c Sat Aug 22 17:52:17 2009
@@ -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) {
Index: src/usr.bin/nbperf/nbperf.c
diff -u src/usr.bin/nbperf/nbperf.c:1.1 src/usr.bin/nbperf/nbperf.c:1.2
--- src/usr.bin/nbperf/nbperf.c:1.1 Sat Aug 15 16:21:05 2009
+++ src/usr.bin/nbperf/nbperf.c Sat Aug 22 17:52:17 2009
@@ -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);
}
Index: src/usr.bin/nbperf/nbperf.h
diff -u src/usr.bin/nbperf/nbperf.h:1.1 src/usr.bin/nbperf/nbperf.h:1.2
--- src/usr.bin/nbperf/nbperf.h:1.1 Sat Aug 15 16:21:05 2009
+++ src/usr.bin/nbperf/nbperf.h Sat Aug 22 17:52:17 2009
@@ -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;