Fix -Wsign-conversion warnings/errors

GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
This commit is contained in:
Philipp A Hartmann 2018-07-15 16:01:02 +02:00 committed by Philipp A Hartmann
parent fa5963a2f5
commit a26267d16d
3 changed files with 4 additions and 4 deletions

View File

@ -464,7 +464,7 @@ public:
enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size())); enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) { for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType; typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;
char buffer[256 + 24]; char buffer[256u + 24];
MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer)); MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer));
EnumHasherType h(&hasherAllocator, 256); EnumHasherType h(&hasherAllocator, 256);
itr->Accept(h); itr->Accept(h);

View File

@ -1762,7 +1762,7 @@ private:
typename DocumentType::AllocatorType documentAllocator_; typename DocumentType::AllocatorType documentAllocator_;
typename SchemaDocumentType::AllocatorType schemaAllocator_; typename SchemaDocumentType::AllocatorType schemaAllocator_;
char documentBuffer_[16384]; char documentBuffer_[16384];
char schemaBuffer_[128 * 1024]; char schemaBuffer_[128u * 1024];
}; };
TEST(SchemaValidator, TestSuite) { TEST(SchemaValidator, TestSuite) {

View File

@ -109,8 +109,8 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnesca
template <unsigned parseFlags, typename StreamType> template <unsigned parseFlags, typename StreamType>
void TestScanCopyUnescapedString() { void TestScanCopyUnescapedString() {
char buffer[1024 + 5 + 32]; char buffer[1024u + 5 + 32];
char backup[1024 + 5 + 32]; char backup[1024u + 5 + 32];
// Test "ABCDABCD...\\" // Test "ABCDABCD...\\"
for (size_t offset = 0; offset < 32; offset++) { for (size_t offset = 0; offset < 32; offset++) {