svadev AT lists.siebelschool.illinois.edu
Subject: Svadev mailing list
List archive
- From: Pavel Borzenkov <pavel.borzenkov AT gmail.com>
- To: svadev AT cs.uiuc.edu
- Subject: [svadev] Fix SAFECode compilation warnings
- Date: Wed, 26 Oct 2011 14:32:36 +0400
- List-archive: <http://lists.cs.uiuc.edu/pipermail/svadev>
- List-id: <svadev.cs.uiuc.edu>
Hi.
GCC reports the following warnings when compiling SAFECode on 32-bit
Linux host in the Release configuration:
{{{
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp:
In function ‘void* __pa_bitmap_poolalloc(llvm::BitmapPoolTy*, unsigned
int)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp:212:
warning: unused variable ‘Idx’
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp:
In function ‘void* poolallocarray(llvm::BitmapPoolTy*, unsigned int)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp:316:
warning: unused variable ‘Idx’
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:
In function ‘void pool_register_global(llvm::DebugPoolTy*, void*,
unsigned int)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:414:
warning: ‘end’ may be used uninitialized in this function
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:414:
note: ‘end’ was declared here
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:
In function ‘void pool_register_global_debug(llvm::DebugPoolTy*,
void*, unsigned int, unsigned int, const char*, unsigned int)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:414:
warning: ‘end’ may be used uninitialized in this function
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/PoolAllocatorBitMask.cpp:414:
note: ‘end’ was declared here
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/RuntimeChecks.cpp:
In function ‘bool _barebone_poolcheck(llvm::DebugPoolTy*, void*,
unsigned int, void*&, void*&)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/RuntimeChecks.cpp:120:
warning: suggest parentheses around assignment used as truth value
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/RuntimeChecks.cpp:
In function ‘void poolcheckui_debug(llvm::DebugPoolTy*, void*,
unsigned int, unsigned int, const char*, unsigned int)’:
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/RuntimeChecks.cpp:353:
warning: suggest parentheses around assignment used as truth value
llvm[2]: Compiling ScanfSupport.cpp for Release build
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/ScanfSupport.cpp:428:
warning: integer constant is too large for ‘unsigned long’ type
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/ScanfSupport.cpp:429:
warning: integer constant is too large for ‘unsigned long’ type
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/ScanfSupport.cpp:430:
warning: integer constant is too large for ‘unsigned long’ type
/home/pavel/projects/safecode/llvm/projects/safecode/runtime/DebugRuntime/ScanfSupport.cpp:431:
warning: integer constant is too large for ‘unsigned long’ type
}}}
The attached patch fixes these warnings.
--
Pavel
Index: runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp =================================================================== --- runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp (revision 143015) +++ runtime/BitmapPoolAllocator/PoolAllocatorBitMask.cpp (working copy) @@ -211,6 +211,7 @@ int Idx = New->allocateSingle(); assert(Idx == 0 && "New allocation didn't return zero'th node?"); + if (Idx != 0) abort(); if (logregs) { fprintf(stderr, " poolalloc:967: canonical page at 0x%p from underlying allocator\n", (void*)New); } @@ -315,6 +316,7 @@ int Idx = New->allocateMultiple(Size); assert(Idx == 0 && "New allocation didn't return zero'th node?"); + if (Idx != 0) abort(); return New->getElementAddress(0, 0); } Index: runtime/DebugRuntime/RuntimeChecks.cpp =================================================================== --- runtime/DebugRuntime/RuntimeChecks.cpp (revision 143015) +++ runtime/DebugRuntime/RuntimeChecks.cpp (working copy) @@ -117,7 +117,7 @@ // itself. // #if 1 - if (ObjStart = __pa_bitmap_poolcheck (Pool, Node)) { + if ((ObjStart = __pa_bitmap_poolcheck (Pool, Node))) { ObjEnd = (unsigned char *) ObjStart + Pool->NodeSize - 1; updateCache (Pool, ObjStart, ObjEnd); return true; @@ -350,7 +350,7 @@ // are stored in this splay tree. // int fs = 0; - if (fs = ExternalObjects->find (Node, ObjStart, ObjEnd)) { + if ((fs = ExternalObjects->find (Node, ObjStart, ObjEnd))) { if ((ObjStart <= Node) && (Node <= ObjEnd)) { if (!((ObjStart <= NodeEnd) && (NodeEnd <= ObjEnd))) { DebugViolationInfo v; Index: runtime/DebugRuntime/PoolAllocatorBitMask.cpp =================================================================== --- runtime/DebugRuntime/PoolAllocatorBitMask.cpp (revision 143015) +++ runtime/DebugRuntime/PoolAllocatorBitMask.cpp (working copy) @@ -410,14 +410,13 @@ // If it's an overlapping global object, register the larger size. // if (allocationType == Global) { - void * start; - void * end; -#ifndef NDEBUG + void * start = NULL; + void * end = NULL; + bool fs = SPTree->find (allocaptr, start, end); assert (fs); -#else - SPTree->find (allocaptr, start, end); -#endif + if (fs == false) abort(); + if (((unsigned char *)allocaptr + NumBytes - 1) > end) { SPTree->remove (allocaptr); SPTree->insert(allocaptr, (char*) allocaptr + NumBytes - 1); Index: runtime/DebugRuntime/ScanfSupport.cpp =================================================================== --- runtime/DebugRuntime/ScanfSupport.cpp (revision 143015) +++ runtime/DebugRuntime/ScanfSupport.cpp (working copy) @@ -425,10 +425,10 @@ const scanset_t all_chars = { scanset_t::TABLE, - { { 0xfffffffffffffffful, - 0xfffffffffffffffful, - 0xfffffffffffffffful, - 0xfffffffffffffffful } } + { { 0xffffffffffffffffull, + 0xffffffffffffffffull, + 0xffffffffffffffffull, + 0xffffffffffffffffull } } }; // Clear the scanset.
- [svadev] Fix SAFECode compilation warnings, Pavel Borzenkov, 10/26/2011
Archive powered by MHonArc 2.6.16.