aboutsummaryrefslogtreecommitdiff
path: root/tools/test
diff options
context:
space:
mode:
authorRebecca Cran <brucec@FreeBSD.org>2011-03-11 17:33:31 +0000
committerRebecca Cran <brucec@FreeBSD.org>2011-03-11 17:33:31 +0000
commit01ded8b942effbbb4d9225c4227f264e499e9698 (patch)
treedbd75672eeaf615376dfe6a3b351a92771f0691f /tools/test
parentb94338d4f072363f417096f1846f4058812f6fe0 (diff)
downloadsrc-01ded8b942effbbb4d9225c4227f264e499e9698.tar.gz
src-01ded8b942effbbb4d9225c4227f264e499e9698.zip
Fix warnings and style(9) issues.
Set WARNS to 6. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=219511
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/malloc/Makefile1
-rw-r--r--tools/test/malloc/main.c29
2 files changed, 16 insertions, 14 deletions
diff --git a/tools/test/malloc/Makefile b/tools/test/malloc/Makefile
index 7d6067087b6b..2f00c341fa0a 100644
--- a/tools/test/malloc/Makefile
+++ b/tools/test/malloc/Makefile
@@ -4,6 +4,7 @@ SRCS= main.c
.PATH: ${.CURDIR}/../../../lib/libc/stdlib
NO_MAN=
+WARNS?=6
test: malloc
@echo
diff --git a/tools/test/malloc/main.c b/tools/test/malloc/main.c
index 2a0502928c06..5fef9a92f4da 100644
--- a/tools/test/malloc/main.c
+++ b/tools/test/malloc/main.c
@@ -1,6 +1,7 @@
/* $FreeBSD$ */
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
u_long NBUCKETS = 2000;
@@ -12,25 +13,25 @@ char **foo;
int
main(int argc, char **argv)
{
- int i,j,k;
+ u_long i,j,k;
if (argc > 1) NOPS = strtoul(argv[1],0,0);
if (argc > 2) NBUCKETS = strtoul(argv[2],0,0);
if (argc > 3) NSIZE = strtoul(argv[3],0,0);
- printf("BRK(0)=%x ",sbrk(0));
- foo = malloc (sizeof *foo * NBUCKETS);
- memset(foo,0,sizeof *foo * NBUCKETS);
+ printf("BRK(0)=%p ", sbrk(0));
+ foo = malloc(sizeof(*foo) * NBUCKETS);
+ memset(foo, 0, sizeof(*foo) * NBUCKETS);
for (i = 1; i <= 4096; i *= 2) {
- for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
+ for (j = 0; j < 40960/i && j < NBUCKETS; j++) {
foo[j] = malloc(i);
}
- for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
+ for (j = 0; j < 40960/i && j < NBUCKETS; j++) {
free(foo[j]);
- foo[j] = 0;
+ foo[j] = NULL;
}
}
- for (i = 0 ; i < NOPS ; i++) {
+ for (i = 0; i < NOPS; i++) {
j = random() % NBUCKETS;
k = random() % NSIZE;
foo[j] = realloc(foo[j], k & 1 ? 0 : k);
@@ -39,19 +40,19 @@ main(int argc, char **argv)
* Workaround because realloc return bogus pointer rather than
* NULL if passed zero length.
*/
- foo[j] = 0;
+ foo[j] = NULL;
}
if (foo[j])
foo[j][0] = 1;
}
- printf("BRK(1)=%x ",sbrk(0));
- for (j = 0 ; j < NBUCKETS ; j++) {
+ printf("BRK(1)=%p ", sbrk(0));
+ for (j = 0; j < NBUCKETS; j++) {
if (foo[j]) {
free(foo[j]);
- foo[j] = 0;
+ foo[j] = NULL;
}
}
- printf("BRK(2)=%x NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n",
- sbrk(0),NOPS,NBUCKETS,NSIZE);
+ printf("BRK(2)=%p NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n",
+ sbrk(0), NOPS, NBUCKETS, NSIZE);
return 0;
}