BinaryStream - fix static analyzer warnings. NFCI.

- uninitialized variables
 - documention warnings
 - shadow variable names
This commit is contained in:
Simon Pilgrim 2019-11-08 13:10:52 +00:00
parent 28aab49c05
commit e3b5671420
4 changed files with 13 additions and 13 deletions

View File

@ -133,9 +133,9 @@ public:
Extractor &getExtractor() { return E; }
BinaryStreamRef getUnderlyingStream() const { return Stream; }
void setUnderlyingStream(BinaryStreamRef S, uint32_t Skew = 0) {
Stream = S;
this->Skew = Skew;
void setUnderlyingStream(BinaryStreamRef NewStream, uint32_t NewSkew = 0) {
Stream = NewStream;
Skew = NewSkew;
}
void drop_front() { Skew += begin()->length(); }
@ -143,7 +143,7 @@ public:
private:
BinaryStreamRef Stream;
Extractor E;
uint32_t Skew;
uint32_t Skew = 0;
};
template <typename ValueType, typename Extractor>

View File

@ -148,14 +148,14 @@ public:
/// returns an appropriate error code.
Error readStreamRef(BinaryStreamRef &Ref, uint32_t Length);
/// Read \p Length bytes from the underlying stream into \p Stream. This is
/// Read \p Length bytes from the underlying stream into \p Ref. This is
/// equivalent to calling getUnderlyingStream().slice(Offset, Length).
/// Updates the stream's offset to point after the newly read object. Never
/// causes a copy.
///
/// \returns a success error code if the data was successfully read, otherwise
/// returns an appropriate error code.
Error readSubstream(BinarySubstreamRef &Stream, uint32_t Size);
Error readSubstream(BinarySubstreamRef &Ref, uint32_t Length);
/// Get a pointer to an object of type T from the underlying stream, as if by
/// memcpy, and store the result into \p Dest. It is up to the caller to

View File

@ -198,7 +198,7 @@ public:
};
struct BinarySubstreamRef {
uint32_t Offset; // Offset in the parent stream
uint32_t Offset = 0; // Offset in the parent stream
BinaryStreamRef StreamData; // Stream Data
BinarySubstreamRef slice(uint32_t Off, uint32_t Size) const {
@ -211,8 +211,8 @@ struct BinarySubstreamRef {
BinarySubstreamRef keep_front(uint32_t N) const { return slice(0, N); }
std::pair<BinarySubstreamRef, BinarySubstreamRef>
split(uint32_t Offset) const {
return std::make_pair(keep_front(Offset), drop_front(Offset));
split(uint32_t Off) const {
return std::make_pair(keep_front(Off), drop_front(Off));
}
uint32_t size() const { return StreamData.getLength(); }

View File

@ -139,10 +139,10 @@ Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref, uint32_t Length) {
return Error::success();
}
Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Stream,
uint32_t Size) {
Stream.Offset = getOffset();
return readStreamRef(Stream.StreamData, Size);
Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Ref,
uint32_t Length) {
Ref.Offset = getOffset();
return readStreamRef(Ref.StreamData, Length);
}
Error BinaryStreamReader::skip(uint32_t Amount) {