Skip to content

Commit fc6cb3f

Browse files
committed
Address misc. linter reports
1 parent ac1d366 commit fc6cb3f

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

src/api/Compressor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,10 @@ KANZI_API int CDECL compress(struct cContext* pCtx, const unsigned char* src, si
258258
// Cleanup allocated internal data structures
259259
KANZI_API int CDECL disposeCompressor(struct cContext** ppCtx, size_t* outSize) KANZI_NOEXCEPT
260260
{
261-
*outSize = 0;
262-
263-
if ((ppCtx == nullptr) || (*ppCtx == nullptr))
261+
if ((ppCtx == nullptr) || (*ppCtx == nullptr) || (outSize == nullptr))
264262
return Error::ERR_INVALID_PARAM;
265263

264+
*outSize = 0;
266265
cContext* pCtx = *ppCtx;
267266
CompressedOutputStream* pCos = pCtx->pCos;
268267

src/app/BlockDecompressor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ int BlockDecompressor::decompress(uint64& inputSize)
387387
}
388388

389389
ss << "Total output size: " << read << (read > 1 ? " bytes" : " byte") << endl;
390-
log.print(ss.str(), _verbosity > 0);
390+
log.print(ss.str(), true);
391391
ss.str(string());
392392
}
393393

src/app/InfoPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void InfoPrinter::processEvent(const Event& evt)
7373
}
7474
}
7575
else if (evt.getType() == _thresholds[2]) {
76-
BlockInfo* bi = _map[hash(currentBlockId)];
76+
const BlockInfo* bi = _map[hash(currentBlockId)];
7777

7878
if (bi == nullptr)
7979
return;
@@ -244,10 +244,10 @@ void InfoPrinter::processHeaderInfo(const Event& evt)
244244
size_t idx = inputName.find_last_of(PATH_SEPARATOR);
245245

246246
if (idx != string::npos)
247-
inputName = inputName.substr(idx + 1);
247+
inputName.erase(0, idx + 1);
248248

249249
if (inputName.length() > 20)
250-
inputName = inputName.substr(0, 18) + "..";
250+
inputName.replace(18, string::npos, "..");
251251

252252
ss << std::left << setw(20) << inputName << "|" << std::right; // inputName
253253
}
@@ -296,7 +296,7 @@ void InfoPrinter::processHeaderInfo(const Event& evt)
296296
string t = tokens[5];
297297

298298
if (t.length() > 26)
299-
t = t.substr(0, 24) + "..";
299+
t = t.replace(24, string::npos, "..");
300300

301301
ss << setw(26) << (t == "" ? "NONE" : t) << "|"; // transforms
302302
}

src/entropy/CMPredictor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ CMPredictor::CMPredictor()
4545
}
4646

4747
_pc1 = _counter1[_ctx];
48-
_pc2 = &_counter2[_ctx | _runMask][8];
48+
_pc2 = &_counter2[_ctx][8];
4949
}

src/entropy/FPAQDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ bool FPAQDecoder::reset()
4747
_high = TOP;
4848
_current = 0;
4949
_ctx = 1;
50+
_index = 0;
5051

5152
for (int i = 0; i < 4; i++) {
5253
for (int j = 0; j < 256; j++)
@@ -73,7 +74,7 @@ int FPAQDecoder::decode(byte block[], uint blkptr, uint count)
7374
if (szBytes >= 2 * count)
7475
return 0;
7576

76-
const size_t bufSize = max(szBytes + (szBytes >> 2), 8192u);
77+
const size_t bufSize = max(szBytes + (szBytes >> 3), 8192u);
7778

7879
if (_buf.size() < bufSize)
7980
_buf.resize(bufSize);

src/entropy/FPAQDecoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace kanzi
4444
uint64 _current;
4545
InputBitStream& _bitstream;
4646
std::vector<byte> _buf;
47-
int _index;
47+
uint _index;
4848
uint16 _probs[4][256]; // probability of bit=1
4949
uint16* _p; // pointer to current prob
5050
int _ctx; // previous bits

src/entropy/FPAQEncoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ int FPAQEncoder::encode(const byte block[], uint blkptr, uint count)
6262

6363
uint startChunk = blkptr;
6464
const uint end = blkptr + count;
65+
const size_t bufSize = max(DEFAULT_CHUNK_SIZE + (DEFAULT_CHUNK_SIZE >> 3), 1024u);
66+
67+
if (_buf.size() < bufSize)
68+
_buf.resize(bufSize);
6569

6670
// Split block into chunks, encode chunk and write bit array to bitstream
6771
while (startChunk < end) {
6872
const uint chunkSize = min(DEFAULT_CHUNK_SIZE, end - startChunk);
69-
const size_t bufSize = max(chunkSize + (chunkSize >> 3), 1024u);
70-
71-
if (_buf.size() < bufSize)
72-
_buf.resize(bufSize);
7373

7474
_index = 0;
7575
const uint endChunk = startChunk + chunkSize;

src/entropy/FPAQEncoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace kanzi
4444
bool _disposed;
4545
OutputBitStream& _bitstream;
4646
std::vector<byte> _buf;
47-
int _index;
47+
uint _index;
4848
uint16 _probs[4][256]; // probability of bit=1
4949

5050

src/io/CompressedInputStream.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,14 @@ void CompressedInputStream::readHeader()
646646
string inputName = _ctx.getString("inputName", "");
647647
ss << inputName << ",";
648648
ss << bsVersion << ",";
649-
string ckSize = "0";
649+
string ckBits = "0";
650650

651651
if (_hasher32 != nullptr)
652-
ckSize = "32";
652+
ckBits = "32";
653653
else if (_hasher64 != nullptr)
654-
ckSize = "64";
654+
ckBits = "64";
655655

656-
ss << ckSize << ",";
656+
ss << ckBits << ",";
657657
ss << _blockSize << ",";
658658
string w1 = EntropyDecoderFactory::getName(_entropyType);
659659
ss << ((w1 == "NONE") ? "" : w1) << ",";

src/transform/LZCodec.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
393393

394394
while (srcIdx + 4 < anchor) {
395395
srcIdx += 4;
396-
const int32 h0 = hash(&src[srcIdx - 3]);
397-
const int32 h1 = hash(&src[srcIdx - 2]);
398-
const int32 h2 = hash(&src[srcIdx - 1]);
399-
const int32 h3 = hash(&src[srcIdx - 0]);
400-
_hashes[h0] = srcIdx - 3;
401-
_hashes[h1] = srcIdx - 2;
402-
_hashes[h2] = srcIdx - 1;
403-
_hashes[h3] = srcIdx - 0;
396+
const int32 hh0 = hash(&src[srcIdx - 3]);
397+
const int32 hh1 = hash(&src[srcIdx - 2]);
398+
const int32 hh2 = hash(&src[srcIdx - 1]);
399+
const int32 hh3 = hash(&src[srcIdx - 0]);
400+
_hashes[hh0] = srcIdx - 3;
401+
_hashes[hh1] = srcIdx - 2;
402+
_hashes[hh2] = srcIdx - 1;
403+
_hashes[hh3] = srcIdx - 0;
404404
}
405405

406406
while (++srcIdx < anchor) {

0 commit comments

Comments
 (0)