From 9f897ba822dc017b6858eef2a1c3ce10d13b577a Mon Sep 17 00:00:00 2001
From: Richard Brooksby
Date: Mon, 26 Mar 2012 14:21:40 +0100
Subject: Fixing printf(var) to printf("%s", var) to suppress warnings (and
improve code).
Copied from Perforce
Change: 177792
ServerID: perforce.ravenbrook.com
---
mps/code/locbwcss.c | 30 +++++++++++++++---------------
mps/code/locusss.c | 40 ++++++++++++++++++++--------------------
mps/code/segsmss.c | 14 +++++++-------
mps/code/steptest.c | 4 ++--
4 files changed, 44 insertions(+), 44 deletions(-)
(limited to 'mps/code')
diff --git a/mps/code/locbwcss.c b/mps/code/locbwcss.c
index 5ce042c1692..3d85576b4fc 100644
--- a/mps/code/locbwcss.c
+++ b/mps/code/locbwcss.c
@@ -31,7 +31,7 @@
((size_t)((char *)(l) - (char *)(b)))
-/* PoolStat -- maintain data about contiguous allocations */
+/* PoolStat -- maintain data about contiguous allocations */
typedef struct PoolStatStruct *PoolStat;
@@ -100,7 +100,7 @@ static void poolStatInit(PoolStat stat, mps_pool_t pool, size_t objSize)
s3 = allocObject(pool, objSize / 2);
recordNewObjectStat(stat, s3);
- mps_free(pool, s2, objSize / 2);
+ mps_free(pool, s2, objSize / 2);
recordFreedObjectStat(stat);
}
@@ -120,7 +120,7 @@ static void allocMultiple(PoolStat stat)
/* free one of the objects, to make the test more interesting */
i = rnd() % allocsPerIteration;
- mps_free(stat->pool, objects[i], stat->objSize);
+ mps_free(stat->pool, objects[i], stat->objSize);
recordFreedObjectStat(stat);
}
@@ -131,11 +131,11 @@ static void allocMultiple(PoolStat stat)
static void reportResults(PoolStat stat, char *name)
{
printf("\nResults for ");
- printf(name);
+ fputs(name, stdout);
printf("\n");
printf(" Allocated %lu objects\n", (unsigned long)stat->aCount);
printf(" Freed %lu objects\n", (unsigned long)stat->fCount);
- printf(" There were %lu non-contiguous allocations\n",
+ printf(" There were %lu non-contiguous allocations\n",
(unsigned long)stat->ncCount);
printf(" Address range from %p to %p\n",
(void *)stat->min, (void *)stat->max);
@@ -152,13 +152,13 @@ static void testInArena(mps_arena_t arena)
PoolStat histat = &histruct;
int i;
- die(mps_pool_create(&hipool, arena, mps_class_mvff(),
- chunkSize, chunkSize, 1024,
+ die(mps_pool_create(&hipool, arena, mps_class_mvff(),
+ chunkSize, chunkSize, 1024,
TRUE, TRUE, TRUE),
"Create HI MFFV");
- die(mps_pool_create(&lopool, arena, mps_class_mvff(),
- chunkSize, chunkSize, 1024,
+ die(mps_pool_create(&lopool, arena, mps_class_mvff(),
+ chunkSize, chunkSize, 1024,
FALSE, FALSE, TRUE),
"Create LO MFFV");
@@ -174,7 +174,7 @@ static void testInArena(mps_arena_t arena)
/* report results */
reportResults(lostat, "the low MVFF pool");
reportResults(histat, "the high MVFF pool");
-
+
if (lostat->max > histat->min) {
printf("\nFOUND PROBLEM - low range overlaps high\n");
} else if (lostat->ncCount != 0 || histat->ncCount != 0) {
@@ -210,18 +210,18 @@ int main(int argc, char **argv)
* Copyright (C) 2001-2002 Ravenbrook Limited .
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* 3. Redistributions in any form must be accompanied by information on how
* to obtain complete source code for this software and any accompanying
* software that uses this software. The source code must either be
@@ -232,7 +232,7 @@ int main(int argc, char **argv)
* include source code for modules or files that typically accompany the
* major components of the operating system on which the executable file
* runs.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
diff --git a/mps/code/locusss.c b/mps/code/locusss.c
index 1b8708bd31a..bd1ab6584a6 100644
--- a/mps/code/locusss.c
+++ b/mps/code/locusss.c
@@ -32,7 +32,7 @@
((size_t)((char *)(l) - (char *)(b)))
-/* PoolStat -- maintain data about contiguous allocations */
+/* PoolStat -- maintain data about contiguous allocations */
typedef struct PoolStatStruct *PoolStat;
@@ -100,7 +100,7 @@ static void poolStatInit(PoolStat stat, mps_pool_t pool, size_t objSize)
s3 = allocObject(pool, objSize / 2);
recordNewObjectStat(stat, s3);
- mps_free(pool, s2, objSize / 2);
+ mps_free(pool, s2, objSize / 2);
recordFreedObjectStat(stat);
}
@@ -123,7 +123,7 @@ static mps_res_t allocMultiple(PoolStat stat)
/* free one of the objects, to make the test more interesting */
i = rnd() % contigAllocs;
- mps_free(stat->pool, objects[i], stat->objSize);
+ mps_free(stat->pool, objects[i], stat->objSize);
recordFreedObjectStat(stat);
return MPS_RES_OK;
@@ -135,19 +135,19 @@ static mps_res_t allocMultiple(PoolStat stat)
static void reportResults(PoolStat stat, char *name)
{
printf("\nResults for ");
- printf(name);
+ printf("%s", name);
printf("\n");
printf(" Allocated %lu objects\n", (unsigned long)stat->aCount);
printf(" Freed %lu objects\n", (unsigned long)stat->fCount);
- printf(" There were %lu non-contiguous allocations\n",
+ printf(" There were %lu non-contiguous allocations\n",
(unsigned long)stat->ncCount);
printf(" Address range from %p to %p\n", stat->min, stat->max);
printf("\n");
}
-static void testInArena(mps_arena_t arena,
- mps_bool_t failcase,
+static void testInArena(mps_arena_t arena,
+ mps_bool_t failcase,
mps_bool_t usefulFailcase)
{
mps_pool_t lopool, hipool, temppool;
@@ -159,17 +159,17 @@ static void testInArena(mps_arena_t arena,
PoolStat tempstat = &tempstruct;
int i;
- die(mps_pool_create(&hipool, arena, mps_class_mvff(),
- chunkSize, chunkSize, 1024,
+ die(mps_pool_create(&hipool, arena, mps_class_mvff(),
+ chunkSize, chunkSize, 1024,
TRUE, TRUE, TRUE),
"Create HI MFFV");
- die(mps_pool_create(&lopool, arena, mps_class_mvff(),
- chunkSize, chunkSize, 1024,
+ die(mps_pool_create(&lopool, arena, mps_class_mvff(),
+ chunkSize, chunkSize, 1024,
FALSE, FALSE, TRUE),
"Create LO MFFV");
- die(mps_pool_create(&temppool, arena, mps_class_mv(),
+ die(mps_pool_create(&temppool, arena, mps_class_mv(),
chunkSize, chunkSize, chunkSize),
"Create TEMP");
@@ -203,15 +203,15 @@ static void testInArena(mps_arena_t arena,
reportResults(lostat, "the low MVFF pool");
reportResults(histat, "the high MVFF pool");
reportResults(tempstat, "the temp pool");
-
+
mps_pool_destroy(hipool);
mps_pool_destroy(lopool);
mps_pool_destroy(temppool);
}
-static void runArenaTest(size_t size,
- mps_bool_t failcase,
+static void runArenaTest(size_t size,
+ mps_bool_t failcase,
mps_bool_t usefulFailcase)
{
mps_arena_t arena;
@@ -252,18 +252,18 @@ int main(int argc, char **argv)
* Copyright (C) 2001-2002 Ravenbrook Limited .
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* 3. Redistributions in any form must be accompanied by information on how
* to obtain complete source code for this software and any accompanying
* software that uses this software. The source code must either be
@@ -274,7 +274,7 @@ int main(int argc, char **argv)
* include source code for modules or files that typically accompany the
* major components of the operating system on which the executable file
* runs.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c
index a02475fe5d7..83d919b9995 100644
--- a/mps/code/segsmss.c
+++ b/mps/code/segsmss.c
@@ -790,7 +790,7 @@ static void *test(void *arg, size_t s)
&ambigRoots[0], ambigRootsCOUNT),
"root_create_table(ambig)");
- printf(indent);
+ fputs(indent, stdout);
/* create an ap, and leave it busy */
die(mps_reserve(&busy_init, busy_ap, 64), "mps_reserve busy");
@@ -801,7 +801,7 @@ static void *test(void *arg, size_t s)
lastStep = totalSize;
printf("\nSize %lu bytes, %lu objects.\n",
(unsigned long)totalSize, objs);
- printf(indent);
+ printf("%s", indent);
fflush(stdout);
for(i = 0; i < exactRootsCOUNT; ++i)
cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]),
@@ -875,18 +875,18 @@ int main(int argc, char **argv)
* Copyright (C) 2001-2002 Ravenbrook Limited .
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* 3. Redistributions in any form must be accompanied by information on how
* to obtain complete source code for this software and any accompanying
* software that uses this software. The source code must either be
@@ -897,7 +897,7 @@ int main(int argc, char **argv)
* include source code for modules or files that typically accompany the
* major components of the operating system on which the executable file
* runs.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
diff --git a/mps/code/steptest.c b/mps/code/steptest.c
index d9e6bf6fd9b..a017da67e87 100644
--- a/mps/code/steptest.c
+++ b/mps/code/steptest.c
@@ -208,7 +208,7 @@ static void print_time(char *before, double t, char *after)
char *x = prefixes+2; /* start at micro */
double ot = t;
if (before)
- printf(before);
+ printf("%s", before);
if (t > MAXPRINTABLE) {
while (x[-1] && t > MAXPRINTABLE) {
t /= 1000.0;
@@ -230,7 +230,7 @@ static void print_time(char *before, double t, char *after)
printf("%g s", ot/1000000.0);
}
if (after)
- printf(after);
+ printf("%s", after);
}
/* Make a single Dylan object */
--
cgit v1.2.1