From d2ad6751d5c8c8f682aad3a0a4deeb8134c07a8f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 1 Sep 2017 20:37:23 -0400 Subject: [PATCH] Clear uninitialized variable warnings under xlC --- asn.cpp | 4 ++-- cast.cpp | 2 +- sha.cpp | 5 ++--- zinflate.cpp | 13 ++++++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/asn.cpp b/asn.cpp index cd7a9337..fb7740b4 100644 --- a/asn.cpp +++ b/asn.cpp @@ -76,7 +76,7 @@ bool BERLengthDecode(BufferedTransformation &bt, lword &length, bool &definiteLe bool BERLengthDecode(BufferedTransformation &bt, size_t &length) { lword lw = 0; - bool definiteLength; + bool definiteLength = false; if (!BERLengthDecode(bt, lw, definiteLength)) BERDecodeError(); if (!SafeConvert(lw, length)) @@ -343,7 +343,7 @@ void EncodedObjectFilter::Put(const byte *inString, size_t length) break; } ByteQueue::Walker walker(m_queue); - bool definiteLength; + bool definiteLength = false; if (!BERLengthDecode(walker, m_lengthRemaining, definiteLength)) return; m_queue.TransferTo(CurrentTarget(), walker.GetCurrentPosition()); diff --git a/cast.cpp b/cast.cpp index 010fef04..352fcdf8 100644 --- a/cast.cpp +++ b/cast.cpp @@ -100,7 +100,7 @@ void CAST128::Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, reduced = (keylength <= 10); - word32 X[4], Z[4]; + word32 X[4], Z[4]={0}; GetUserKey(BIG_ENDIAN_ORDER, X, 4, userKey, keylength); #define x(i) GETBYTE(X[i/4], 3-i%4) diff --git a/sha.cpp b/sha.cpp index 114b1b76..d384b1fd 100644 --- a/sha.cpp +++ b/sha.cpp @@ -261,7 +261,7 @@ ANONYMOUS_NAMESPACE_BEGIN void SHA256_HashBlock_CXX(word32 *state, const word32 *data) { - word32 W[16], T[8]; + word32 W[16]={0}, T[8]; /* Copy context->state[] to working vars */ memcpy(T, state, sizeof(T)); /* 64 operations, partially loop unrolled */ @@ -1043,8 +1043,7 @@ void SHA512_HashBlock_CXX(word64 *state, const word64 *data) CRYPTOPP_ASSERT(state); CRYPTOPP_ASSERT(data); - word64 W[16]; - word64 T[8]; + word64 W[16]={0}, T[8]; /* Copy context->state[] to working vars */ memcpy(T, state, sizeof(T)); /* 80 operations, partially loop unrolled */ diff --git a/zinflate.cpp b/zinflate.cpp index 7e9de15b..f78d3efd 100644 --- a/zinflate.cpp +++ b/zinflate.cpp @@ -377,6 +377,7 @@ void Inflator::DecodeHeader() throw UnexpectedEndErr(); m_eof = m_reader.GetBits(1) != 0; m_blockType = (byte)m_reader.GetBits(2); + switch (m_blockType) { case 0: // stored @@ -400,13 +401,13 @@ void Inflator::DecodeHeader() unsigned int hlit = m_reader.GetBits(5); unsigned int hdist = m_reader.GetBits(5); unsigned int hclen = m_reader.GetBits(4); + unsigned int i = 0; FixedSizeSecBlock codeLengths; - unsigned int i; static const unsigned int border[] = { // Order of the bit length code lengths 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; std::fill(codeLengths.begin(), codeLengths+19, 0); - for (i=0; i