Fix clang warnings in PoolAlloc.cpp

Issue=127 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Part 4 of 5: <http://webkit.org/b/56337> Enable -Werror on ANGLE Upstream bug: <http://code.google.com/p/angleproject/issues/detail?id=127> Fixes the following static analyzer warnings: src/compiler/PoolAlloc.cpp:154:26:{154:24-154:25}{154:28-154:42}: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare,2] for (size_t x = 0; x < guardBlockSize; x++) { ~ ^ ~~~~~~~~~~~~~~ src/compiler/PoolAlloc.cpp:159:55:{159:54-159:56}{160:30-160:34}: warning: conversion specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat,7] sprintf(assertMsg, "PoolAlloc: Damage %s %u byte allocation at 0x%p\n", ~^ %lu fix-it:"src/compiler/PoolAlloc.cpp":{159:54-159:56}:"%lu" * src/compiler/PoolAlloc.cpp: (TAllocation::checkGuardBlock): Changed '%u' to '%lu' for size_t variable. Put for loop inside #ifdef GUARD_BLOCKS/#endif macros to fix tautological-compare warning. (TAllocation::checkAllocList): Added newline to end of file. Author: David Kilzer <ddkilzer@apple.com> git-svn-id: https://angleproject.googlecode.com/svn/trunk@575 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ea993576
...@@ -151,16 +151,18 @@ const unsigned char TAllocation::userDataFill = 0xcd; ...@@ -151,16 +151,18 @@ const unsigned char TAllocation::userDataFill = 0xcd;
// //
void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const
{ {
#ifdef GUARD_BLOCKS
for (size_t x = 0; x < guardBlockSize; x++) { for (size_t x = 0; x < guardBlockSize; x++) {
if (blockMem[x] != val) { if (blockMem[x] != val) {
char assertMsg[80]; char assertMsg[80];
// We don't print the assert message. It's here just to be helpful. // We don't print the assert message. It's here just to be helpful.
sprintf(assertMsg, "PoolAlloc: Damage %s %u byte allocation at 0x%p\n", sprintf(assertMsg, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
locText, size, data()); locText, size, data());
assert(0 && "PoolAlloc: Damage in guard block"); assert(0 && "PoolAlloc: Damage in guard block");
} }
} }
#endif
} }
...@@ -299,4 +301,4 @@ void TAllocation::checkAllocList() const ...@@ -299,4 +301,4 @@ void TAllocation::checkAllocList() const
{ {
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc) for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
alloc->check(); alloc->check();
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment