fixed warnings for [coding]

This commit is contained in:
Sergey Yershov 2015-03-17 16:36:48 +03:00 committed by Alex Zolotarev
parent 3848db2389
commit 217de72ef7
13 changed files with 41 additions and 35 deletions

View file

@ -86,7 +86,7 @@ namespace my
s << " " << m_names[level];
double const sec = m_timer.ElapsedSeconds();
s << " " << setfill(' ') << setw(16 - m_lens[level]) << sec << " ";
s << " " << setfill(' ') << setw(static_cast<int>(16 - m_lens[level])) << sec << " ";
}
};

View file

@ -6,6 +6,8 @@
#include "../base/assert.hpp"
#include "../base/bits.hpp"
#include "../std/limits.hpp"
vector<uint32_t> FreqsToDistrTable(vector<uint32_t> const & origFreqs)
{
uint64_t freqLowerBound = 0;
@ -19,8 +21,10 @@ vector<uint32_t> FreqsToDistrTable(vector<uint32_t> const & origFreqs)
for (uint32_t i = 0; i < origFreqs.size(); ++i)
{
uint32_t freq = origFreqs[i];
if (freq > 0 && freq < minFreq) minFreq = freq;
if (freq > 0 && freq < freqLowerBound) freq = freqLowerBound;
if (freq > 0 && freq < minFreq)
minFreq = freq;
if (freq > 0 && freq < freqLowerBound)
freq = static_cast<uint32_t>(freqLowerBound);
freqs.push_back(freq);
sum += freq;
result.push_back(sum);
@ -89,7 +93,8 @@ vector<uint8_t> ArithmeticEncoder::Finalize()
void ArithmeticEncoder::PropagateCarry()
{
int i = m_output.size() - 1;
ASSERT(m_output.size() > 0, ());
int i = static_cast<int>(m_output.size() - 1);
while (i >= 0 && m_output[i] == 0xFF)
{
m_output[i] = 0;
@ -112,7 +117,8 @@ ArithmeticDecoder::ArithmeticDecoder(Reader & reader, vector<uint32_t> const & d
uint32_t ArithmeticDecoder::Decode()
{
uint32_t l = 0, r = m_distrTable.size(), m = 0;
ASSERT(m_distrTable.size() <= numeric_limits<uint32_t>::max(), ());
uint32_t l = 0, r = static_cast<uint32_t>(m_distrTable.size()), m = 0;
uint32_t shiftedSize = m_size >> DISTR_SHIFT;
while (r - l > 1)
{

View file

@ -59,7 +59,7 @@ uint64_t BitSource::Read(uint32_t readSize)
// Second read, does an extra read using m_reader.
if (readSize > 0)
{
uint32_t read_byte_size = m_serialCur + sizeof(m_bits) <= m_serialEnd ? sizeof(m_bits) : m_serialEnd - m_serialCur;
size_t read_byte_size = m_serialCur + sizeof(m_bits) <= m_serialEnd ? sizeof(m_bits) : m_serialEnd - m_serialCur;
m_reader.Read(m_serialCur, &m_bits, read_byte_size);
m_serialCur += read_byte_size;
m_bitsSize += read_byte_size * 8;

View file

@ -38,8 +38,8 @@ uint64_t BlobIndexer::AddBlob(string const & blob)
if (m_currentChunk.size() + blob.size() > m_maxUncompressedChunkSize)
FlushChunk();
m_blobChunkAndOffset.push_back(
(m_chunkOffset.size() << BITS_IN_CHUNK_SIZE) + m_currentChunk.size());
m_blobChunkAndOffset.push_back(static_cast<uint32_t>(
(m_chunkOffset.size() << BITS_IN_CHUNK_SIZE) + m_currentChunk.size()));
m_currentChunk.insert(m_currentChunk.end(), blob.begin(), blob.end());
@ -55,7 +55,7 @@ void BlobIndexer::FlushChunk()
m_writer.Write(compressedChunk.data(), compressedChunk.size());
WriteToSink(m_writer, static_cast<uint32_t>(m_currentChunk.size()));
uint32_t const chunkPrevOffset = (m_chunkOffset.empty() ? 0 : m_chunkOffset.back());
m_chunkOffset.push_back(compressedChunk.size() + 4 + chunkPrevOffset);
m_chunkOffset.push_back(static_cast<uint32_t>(compressedChunk.size() + 4 + chunkPrevOffset));
m_currentChunk.clear();
}
}

View file

@ -11,8 +11,8 @@ size_t DecompressBZip2IntoFixedSize(char const * pSrc, size_t srcSize, char * pD
{
// TODO: Remove unnecessary copying.
vector<char> src(pSrc, pSrc + srcSize);
unsigned int dstUsed = dstSize;
int error = BZ2_bzBuffToBuffDecompress(pDst, &dstUsed, &src[0], srcSize, 0, 0);
unsigned int dstUsed = static_cast<unsigned int>(dstSize);
int error = BZ2_bzBuffToBuffDecompress(pDst, &dstUsed, &src[0], static_cast<unsigned int>(srcSize), 0, 0);
switch (error)
{
case BZ_OK:
@ -33,10 +33,10 @@ void CompressBZip2(int level, char const * pSrc, size_t srcSize, string & dst)
{
ASSERT(level >= 1 && level <= 9, (level));
dst.resize(srcSize + srcSize / 100 + 699);
unsigned int dstUsed = dst.size();
unsigned int dstUsed = static_cast<unsigned int>(dst.size());
// TODO: Remove unnecessary copying.
vector<char> src(pSrc, pSrc + srcSize);
int error = BZ2_bzBuffToBuffCompress(&dst[0], &dstUsed, &src[0], srcSize, level, 0, 0);
int error = BZ2_bzBuffToBuffCompress(&dst[0], &dstUsed, &src[0], static_cast<unsigned int>(srcSize), level, 0, 0);
if (error == BZ_OK)
dst.resize(dstUsed);
else

View file

@ -16,7 +16,7 @@ namespace {
vector<uint32_t> SerialFreqsToDistrTable(Reader & reader, uint64_t & decodeOffset, uint64_t cnt)
{
vector<uint32_t> freqs;
for (uint64_t i = 0; i < cnt; ++i) freqs.push_back(VarintDecode(reader, decodeOffset));
for (uint64_t i = 0; i < cnt; ++i) freqs.push_back(static_cast<uint32_t>(VarintDecode(reader, decodeOffset)));
return FreqsToDistrTable(freqs);
}
}
@ -383,12 +383,12 @@ vector<uint32_t> DecodeCompressedBitVector(Reader & reader) {
bool is_empty = (header & 4) != 0;
if (!is_empty)
{
posOnes.push_back(header >> 3);
posOnes.push_back(static_cast<uint32_t>(header >> 3));
prevOnePos = posOnes.back();
}
while (decodeOffset < serialSize)
{
posOnes.push_back(prevOnePos + VarintDecode(reader, decodeOffset) + 1);
posOnes.push_back(static_cast<uint32_t>(prevOnePos + VarintDecode(reader, decodeOffset) + 1));
prevOnePos = posOnes.back();
}
}
@ -412,7 +412,7 @@ vector<uint32_t> DecodeCompressedBitVector(Reader & reader) {
uint32_t bitsUsed = bitsUsedVec[i];
uint64_t diff = 0;
if (bitsUsed > 0) diff = ((uint64_t(1) << (bitsUsed - 1)) | bitReader.Read(bitsUsed - 1)) + 1; else diff = 1;
posOnes.push_back(prevOnePos + diff);
posOnes.push_back(static_cast<uint32_t>(prevOnePos + diff));
prevOnePos += diff;
}
decodeOffset = serialSize;
@ -431,7 +431,8 @@ vector<uint32_t> DecodeCompressedBitVector(Reader & reader) {
if (!isFirstOne) zerosRangeSize = VarintDecode(reader, decodeOffset) + 1; else isFirstOne = false;
uint64_t onesRangeSize = VarintDecode(reader, decodeOffset) + 1;
sum += zerosRangeSize;
for (uint64_t i = sum; i < sum + onesRangeSize; ++i) posOnes.push_back(i);
for (uint64_t i = sum; i < sum + onesRangeSize; ++i)
posOnes.push_back(static_cast<uint32_t>(i));
sum += onesRangeSize;
}
}
@ -475,7 +476,7 @@ vector<uint32_t> DecodeCompressedBitVector(Reader & reader) {
if (bitsUsed > 0) onesRangeSize = ((uint64_t(1) << (bitsUsed - 1)) | bitReader.Read(bitsUsed - 1)) + 1; else onesRangeSize = 1;
++i1;
sum += zerosRangeSize;
for (uint64_t j = sum; j < sum + onesRangeSize; ++j) posOnes.push_back(j);
for (uint64_t j = sum; j < sum + onesRangeSize; ++j) posOnes.push_back(static_cast<uint32_t>(j));
sum += onesRangeSize;
}
CHECK(i0 == cntElements0 && i1 == cntElements1, ());

View file

@ -105,7 +105,8 @@ CompressedVarnumVectorReader::CompressedVarnumVectorReader(Reader & reader)
m_supportSums = VarintDecode(m_reader, offset) != 0;
vector<uint32_t> sizesFreqs;
uint64_t freqsCnt = VarintDecode(m_reader, offset);
for (uint32_t i = 0; i < freqsCnt; ++i) sizesFreqs.push_back(VarintDecode(m_reader, offset));
for (uint32_t i = 0; i < freqsCnt; ++i)
sizesFreqs.push_back(static_cast<uint32_t>(VarintDecode(m_reader, offset)));
m_distrTable = FreqsToDistrTable(sizesFreqs);
m_numsEncodedOffset = offset;

View file

@ -55,7 +55,7 @@ public:
if (size == 0)
return;
ASSERT_LESS_OR_EQUAL(pos + size, reader.Size(), (pos, size, reader.Size()));
m_Stats.m_ReadSize(size);
m_Stats.m_ReadSize(static_cast<uint32_t>(size));
char * pDst = static_cast<char *>(p);
uint64_t pageNum = pos >> m_LogPageSize;
size_t const firstPageOffset = static_cast<size_t>(pos - (pageNum << m_LogPageSize));

View file

@ -56,7 +56,7 @@ void VectorBuilder::AddNum(uint64_t num)
if (m_numsCount % m_numElemPerTableEntry == 0)
{
TableEntry tableEntry;
tableEntry.pos = m_serialNums.size();
tableEntry.pos = static_cast<uint32_t>(m_serialNums.size());
tableEntry.sum = m_sum;
m_selectTable.push_back(tableEntry);
}
@ -143,7 +143,7 @@ void Vector::FindByIndex(uint64_t index, uint32_t & serialPos, uint64_t & sumBef
uint64_t num = VarintDecode(m_reader, numOffset);
sum += num;
}
serialPos = numOffset - m_serialNumsOffset;
serialPos = static_cast<uint32_t>(numOffset - m_serialNumsOffset);
sumBefore = sum;
}
@ -191,7 +191,7 @@ void Vector::FindBySum(uint64_t sum, uint32_t & serialPos, uint64_t & sumBefore,
++countBefore;
}
serialPos = numOffset - m_serialNumsOffset;
serialPos = static_cast<uint32_t>(numOffset - m_serialNumsOffset);
sumBefore = numsSum;
}
@ -201,7 +201,7 @@ void Vector::Read(uint32_t & serialPos, uint64_t & num)
uint64_t numOffset = m_serialNumsOffset + serialPos;
num = VarintDecode(m_reader, numOffset);
serialPos = numOffset - m_serialNumsOffset;
serialPos = static_cast<uint32_t>(numOffset - m_serialNumsOffset);
}
}

View file

@ -92,7 +92,7 @@ bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, str
size_t const toRead = min(ZIP_FILE_BUFFER_SIZE, fileSize - currSize);
file.Read(currSize, &buffer[0], toRead);
if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), &buffer[0], toRead))
if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), &buffer[0], static_cast<uint32_t>(toRead)))
return false;
currSize += toRead;

View file

@ -92,7 +92,7 @@ void RulesHolder::Clean()
m_rules.clear();
}
size_t RulesHolder::AddRule(int scale, rule_type_t type, BaseRule * p)
Key RulesHolder::AddRule(int scale, rule_type_t type, BaseRule * p)
{
ASSERT ( 0 <= scale && scale <= scales::GetUpperStyleScale(), (scale) );
ASSERT ( 0 <= type && type < count_of_rules, () );
@ -103,8 +103,9 @@ size_t RulesHolder::AddRule(int scale, rule_type_t type, BaseRule * p)
v.push_back(static_cast<uint32_t>(m_container[type].size()-1));
int const ret = static_cast<int>(v.size() - 1);
ASSERT ( Find(Key(scale, type, ret)) == p, (ret) );
return ret;
Key k(scale, type, ret);
ASSERT ( Find(k) == p, (ret) );
return k;
}
BaseRule const * RulesHolder::Find(Key const & k) const
@ -287,9 +288,7 @@ namespace
template <class TRule, class TProtoRule>
void AddRule(ClassifObject * p, int scale, rule_type_t type, TProtoRule const & rule)
{
size_t const i = m_holder.AddRule(scale, type, new TRule(rule));
Key k(scale, type, static_cast<int>(i));
Key k = m_holder.AddRule(scale, type, new TRule(rule));
p->SetVisibilityOnScale(true, scale);
k.SetPriority(rule.priority());
p->AddDrawRule(k);

View file

@ -63,7 +63,7 @@ namespace drule
public:
~RulesHolder();
size_t AddRule(int scale, rule_type_t type, BaseRule * p);
Key AddRule(int scale, rule_type_t type, BaseRule * p);
void Clean();

View file

@ -259,8 +259,7 @@ void LoaderCurrent::ParseMetadata()
typedef pair<uint32_t, uint32_t> IdxElementT;
DDVector<IdxElementT, FilesContainerR::ReaderT> idx(m_Info.GetMetadataIndexReader());
auto it = lower_bound(idx.begin(),
idx.end()
auto it = lower_bound(idx.begin(), idx.end()
, make_pair(uint32_t(m_pF->m_id.m_offset), uint32_t(0))
, [](IdxElementT const & v1, IdxElementT const & v2) { return v1.first < v2.first; }
);