[Scummvm-git-logs] scummvm master -> cb4f06fb707a37a1cba4aa58d5b0567a530d6172

csnover csnover at users.noreply.github.com
Thu Mar 30 21:29:14 CEST 2017


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
993d83fe4b COMMON: Reduce maximum Span size to 4GiB
a233696212 SCI: Update formatting strings to match updated Span API
cb4f06fb70 SCI: Avoid shadow warnings in old GCC


Commit: 993d83fe4b65cc30d43ceb4de38c036889a6f4ae
    https://github.com/scummvm/scummvm/commit/993d83fe4b65cc30d43ceb4de38c036889a6f4ae
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-03-30T14:22:56-05:00

Commit Message:
COMMON: Reduce maximum Span size to 4GiB

Until C++11 (which introduces the z and t length modifiers), there
is no consistent way to print size_t and ptrdiff_t types using
printf formatting across 32-bit, LLP64, and LP64 architectures
without using a cumbersome macro to select the appropriate length
modifier for the target architecture. Since ScummVM engines
currently need to support 32-bit targets, there is no reason at
the moment to support any larger memory sizes in Span anyway.

Span error output is also updated in this commit to reflect that
index values are unsigned.

Changed paths:
    common/span.h
    test/common/span.h


diff --git a/common/span.h b/common/span.h
index e11737a..293000381 100644
--- a/common/span.h
+++ b/common/span.h
@@ -268,9 +268,9 @@ class SpanBase : public SafeBool<Derived<ValueType> > {
 
 public:
 	typedef ValueType value_type;
-	typedef ptrdiff_t difference_type;
-	typedef size_t index_type;
-	typedef size_t size_type;
+	typedef int32 difference_type;
+	typedef uint32 index_type;
+	typedef uint32 size_type;
 	typedef SpanInternal::SpanIterator<derived_type, true> const_iterator;
 	typedef SpanInternal::SpanIterator<derived_type, false> iterator;
 	typedef value_type *pointer;
@@ -601,11 +601,11 @@ public:
 				break;
 		}
 
-		return String::format("Access violation %s %s: %ld + %ld > %ld",
+		return String::format("Access violation %s %s: %u + %d > %u",
 							  modeName,
 							  this->impl().name().c_str(),
 							  index,
-							  deltaInBytes / sizeof(value_type),
+							  deltaInBytes / (int)sizeof(value_type),
 							  size());
 	}
 
@@ -829,7 +829,7 @@ public:
 		const size_type maxSizeInBytes = this->impl().byteSize();
 
 		return super_type::getValidationMessage(index, deltaInBytes, mode) +
-			String::format(" (abs: %ld + %ld > %ld)",
+			String::format(" (abs: %u + %d > %u)",
 						   this->impl().sourceByteOffset() + indexInBytes,
 						   deltaInBytes,
 						   this->impl().sourceByteOffset() + maxSizeInBytes);
diff --git a/test/common/span.h b/test/common/span.h
index 55ef2c6..aa3ee9d 100644
--- a/test/common/span.h
+++ b/test/common/span.h
@@ -640,7 +640,7 @@ public:
 		TS_ASSERT(span.checkInvalidBounds(2, -4)); // negative overflow (-2)
 		TS_ASSERT(span.checkInvalidBounds(0, 10)); // delta positive overflow
 
-		const ptrdiff_t big = 1L << (8 * sizeof(ptrdiff_t) - 1);
+		const Common::Span<byte>::difference_type big = 1L << (8 * sizeof(Common::Span<byte>::difference_type) - 1);
 		TS_ASSERT(span.checkInvalidBounds(big, 0));
 		TS_ASSERT(span.checkInvalidBounds(0, big));
 		TS_ASSERT(span.checkInvalidBounds(big, big));
@@ -662,8 +662,8 @@ public:
 		expected = Common::String::format("Access violation writing %s: 23 + 45 > 1", source.c_str());
 		TS_ASSERT_EQUALS(actual, expected);
 
-		actual = span.getValidationMessage(-34, -56, Common::kValidateSeek);
-		expected = Common::String::format("Access violation seeking %s: -34 + -56 > 1", source.c_str());
+		actual = span.getValidationMessage(0, -56, Common::kValidateSeek);
+		expected = Common::String::format("Access violation seeking %s: 0 + -56 > 1", source.c_str());
 		TS_ASSERT_EQUALS(actual, expected);
 	}
 
@@ -716,15 +716,15 @@ public:
 
 		{
 			Common::NamedSpan<byte> subspan = span.subspan(2, Common::kSpanMaxSize, "new.data");
-			expected = "Access violation reading new.data: -34 + -56 > 4 (abs: -32 + -56 > 6)";
-			actual = subspan.getValidationMessage(-34, -56, Common::kValidateRead);
+			expected = "Access violation reading new.data: 0 + -56 > 4 (abs: 2 + -56 > 6)";
+			actual = subspan.getValidationMessage(0, -56, Common::kValidateRead);
 			TS_ASSERT_EQUALS(actual, expected);
 		}
 
 		{
 			Common::NamedSpan<byte> subspan = span.subspan(2, Common::kSpanMaxSize, "new.data", 0);
-			expected = "Access violation reading new.data: -34 + -56 > 4 (abs: -34 + -56 > 4)";
-			actual = subspan.getValidationMessage(-34, -56, Common::kValidateRead);
+			expected = "Access violation reading new.data: 0 + -56 > 4 (abs: 0 + -56 > 4)";
+			actual = subspan.getValidationMessage(0, -56, Common::kValidateRead);
 			TS_ASSERT_EQUALS(actual, expected);
 		}
 
@@ -754,23 +754,23 @@ public:
 
 		{
 			Common::NamedSpan<const byte> subspan = constSpan.subspan(2, Common::kSpanMaxSize, "new.data");
-			expected = "Access violation reading new.data: -34 + -56 > 4 (abs: -32 + -56 > 6)";
-			actual = subspan.getValidationMessage(-34, -56, Common::kValidateRead);
+			expected = "Access violation reading new.data: 0 + -56 > 4 (abs: 2 + -56 > 6)";
+			actual = subspan.getValidationMessage(0, -56, Common::kValidateRead);
 			TS_ASSERT_EQUALS(actual, expected);
 		}
 
 		{
 			Common::NamedSpan<const byte> subspan = constSpan.subspan(2, Common::kSpanMaxSize, "new.data", 0);
-			expected = "Access violation reading new.data: -34 + -56 > 4 (abs: -34 + -56 > 4)";
-			actual = subspan.getValidationMessage(-34, -56, Common::kValidateRead);
+			expected = "Access violation reading new.data: 0 + -56 > 4 (abs: 0 + -56 > 4)";
+			actual = subspan.getValidationMessage(0, -56, Common::kValidateRead);
 			TS_ASSERT_EQUALS(actual, expected);
 		}
 
 		{
 			Common::NamedSpan<const byte> subspan = constSpan.subspan(2, Common::kSpanMaxSize, "new.data", 0);
 			subspan.sourceByteOffset() = 2;
-			expected = "Access violation reading new.data: -34 + -56 > 4 (abs: -32 + -56 > 6)";
-			actual = subspan.getValidationMessage(-34, -56, Common::kValidateRead);
+			expected = "Access violation reading new.data: 0 + -56 > 4 (abs: 2 + -56 > 6)";
+			actual = subspan.getValidationMessage(0, -56, Common::kValidateRead);
 			TS_ASSERT_EQUALS(actual, expected);
 		}
 


Commit: a233696212c1707be4c993de8c36228137475af1
    https://github.com/scummvm/scummvm/commit/a233696212c1707be4c993de8c36228137475af1
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-03-30T14:23:41-05:00

Commit Message:
SCI: Update formatting strings to match updated Span API

Changed paths:
    engines/sci/console.cpp
    engines/sci/engine/message.cpp
    engines/sci/engine/script.cpp
    engines/sci/graphics/palette.cpp
    engines/sci/parser/vocabulary.cpp
    engines/sci/resource.cpp
    engines/sci/resource_audio.cpp
    engines/sci/sound/drivers/midi.cpp


diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index eed0be1..16f5952 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -954,7 +954,7 @@ bool Console::cmdResourceInfo(int argc, const char **argv) {
 	else {
 		Resource *resource = _engine->getResMan()->findResource(ResourceId(res, resNum), 0);
 		if (resource) {
-			debugPrintf("Resource size: %lu\n", resource->size());
+			debugPrintf("Resource size: %u\n", resource->size());
 			debugPrintf("Resource location: %s\n", resource->getResourceLocation().c_str());
 		} else {
 			debugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
@@ -1067,11 +1067,11 @@ bool Console::cmdVerifyScripts(int argc, const char **argv) {
 				debugPrintf("Error: script %d doesn't have a corresponding heap\n", itr->getNumber());
 
 			if (script && heap && (script->size() + heap->size() > 65535))
-				debugPrintf("Error: script and heap %d together are larger than 64KB (%lu bytes)\n",
+				debugPrintf("Error: script and heap %d together are larger than 64KB (%u bytes)\n",
 				itr->getNumber(), script->size() + heap->size());
 		} else {	// SCI3
 			if (script && script->size() > 65535)
-				debugPrintf("Error: script %d is larger than 64KB (%lu bytes)\n",
+				debugPrintf("Error: script %d is larger than 64KB (%u bytes)\n",
 				itr->getNumber(), script->size());
 		}
 	}
diff --git a/engines/sci/engine/message.cpp b/engines/sci/engine/message.cpp
index c30ad3a..baa92616 100644
--- a/engines/sci/engine/message.cpp
+++ b/engines/sci/engine/message.cpp
@@ -82,7 +82,7 @@ public:
 				record.string = (const char *)_data.getUnsafeDataAt(stringOffset, maxSize);
 				record.length = Common::strnlen(record.string, maxSize);
 				if (record.length == maxSize) {
-					warning("Message %s from %s appears truncated at %ld", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
+					warning("Message %s from %s appears truncated at %d", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
 				}
 				return true;
 			}
@@ -110,7 +110,7 @@ public:
 				record.string = (const char *)_data.getUnsafeDataAt(stringOffset, maxSize);
 				record.length = Common::strnlen(record.string, maxSize);
 				if (record.length == maxSize) {
-					warning("Message %s from %s appears truncated at %ld", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
+					warning("Message %s from %s appears truncated at %d", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
 				}
 				return true;
 			}
@@ -138,7 +138,7 @@ public:
 				record.string = (const char *)_data.getUnsafeDataAt(stringOffset, maxSize);
 				record.length = Common::strnlen(record.string, maxSize);
 				if (record.length == maxSize) {
-					warning("Message %s from %s appears truncated at %ld", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
+					warning("Message %s from %s appears truncated at %d", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
 				}
 				return true;
 			}
@@ -169,7 +169,7 @@ public:
 				record.string = (const char *)_data.getUnsafeDataAt(stringOffset, maxSize);
 				record.length = Common::strnlen(record.string, maxSize);
 				if (record.length == maxSize) {
-					warning("Message %s from %s appears truncated at %ld", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
+					warning("Message %s from %s appears truncated at %d", tuple.toString().c_str(), _data.name().c_str(), recordPtr - _data);
 				}
 				return true;
 			}
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index e1ab6ea..a13565c 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -881,7 +881,7 @@ bool Script::isValidOffset(uint16 offset) const {
 
 SegmentRef Script::dereference(reg_t pointer) {
 	if (pointer.getOffset() > _buf->size()) {
-		error("Script::dereference(): Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%lu)",
+		error("Script::dereference(): Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%u)",
 				  PRINT_REG(pointer), _buf->size());
 		return SegmentRef();
 	}
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 307c8ae..e36028d 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -151,7 +151,7 @@ void GfxPalette::createFromData(const SciSpan<const byte> &data, Palette *palett
 	if (data.size() < 37) {
 		// This happens when loading palette of picture 0 in sq5 - the resource is broken and doesn't contain a full
 		//  palette
-		debugC(kDebugLevelResMan, "GfxPalette::createFromData() - not enough bytes in resource (%lu), expected palette header", data.size());
+		debugC(kDebugLevelResMan, "GfxPalette::createFromData() - not enough bytes in resource (%u), expected palette header", data.size());
 		return;
 	}
 
diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp
index 4fefff6..1f062c6 100644
--- a/engines/sci/parser/vocabulary.cpp
+++ b/engines/sci/parser/vocabulary.cpp
@@ -299,7 +299,7 @@ bool Vocabulary::loadAltInputs() {
 		uint32 maxSize = end - it;
 		uint32 l = Common::strnlen(t._input, maxSize);
 		if (l == maxSize) {
-			error("Alt input from %s appears truncated at %ld", resource->name().c_str(), it - resource->cbegin());
+			error("Alt input from %s appears truncated at %d", resource->name().c_str(), it - resource->cbegin());
 		}
 		t._inputLength = l;
 		it += l + 1;
@@ -308,7 +308,7 @@ bool Vocabulary::loadAltInputs() {
 		maxSize = end - it;
 		l = Common::strnlen(t._replacement, maxSize);
 		if (l == maxSize) {
-			error("Alt input replacement from %s appears truncated at %ld", resource->name().c_str(), it - resource->cbegin());
+			error("Alt input replacement from %s appears truncated at %d", resource->name().c_str(), it - resource->cbegin());
 		}
 		it += l + 1;
 
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 6f4248e..6aaf51b 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -309,7 +309,7 @@ bool Resource::loadPatch(Common::SeekableReadStream *file) {
 		_header = new byte[_headerSize];
 
 	if (data() == nullptr || (_headerSize > 0 && _header == nullptr)) {
-		error("Can't allocate %lu bytes needed for loading %s", size() + _headerSize, _id.toString().c_str());
+		error("Can't allocate %u bytes needed for loading %s", size() + _headerSize, _id.toString().c_str());
 	}
 
 	uint32 bytesRead;
@@ -321,7 +321,7 @@ bool Resource::loadPatch(Common::SeekableReadStream *file) {
 
 	bytesRead = file->read(ptr, size());
 	if (bytesRead != size())
-		error("Read %d bytes from %s but expected %lu", bytesRead, _id.toString().c_str(), size());
+		error("Read %d bytes from %s but expected %u", bytesRead, _id.toString().c_str(), size());
 
 	_status = kResStatusAllocated;
 	return true;
@@ -1028,7 +1028,7 @@ void ResourceManager::printLRU() {
 
 	while (it != _LRU.end()) {
 		res = *it;
-		debug("\t%s: %lu bytes", res->_id.toString().c_str(), res->size());
+		debug("\t%s: %u bytes", res->_id.toString().c_str(), res->size());
 		mem += res->size();
 		++entries;
 		++it;
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 0125a0e..7423890 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -85,7 +85,7 @@ bool Resource::loadFromWaveFile(Common::SeekableReadStream *file) {
 
 	uint32 bytesRead = file->read(ptr, _size);
 	if (bytesRead != _size)
-		error("Read %d bytes from %s but expected %lu", bytesRead, _id.toString().c_str(), _size);
+		error("Read %d bytes from %s but expected %u", bytesRead, _id.toString().c_str(), _size);
 
 	_status = kResStatusAllocated;
 	return true;
@@ -139,12 +139,12 @@ bool Resource::loadFromAudioVolumeSCI1(Common::SeekableReadStream *file) {
 	_data = ptr;
 
 	if (!ptr) {
-		error("Can't allocate %lu bytes needed for loading %s", _size, _id.toString().c_str());
+		error("Can't allocate %u bytes needed for loading %s", _size, _id.toString().c_str());
 	}
 
 	uint32 bytesRead = file->read(ptr, size());
 	if (bytesRead != size())
-		warning("Read %d bytes from %s but expected %lu", bytesRead, _id.toString().c_str(), _size);
+		warning("Read %d bytes from %s but expected %u", bytesRead, _id.toString().c_str(), _size);
 
 	_status = kResStatusAllocated;
 	return true;
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index b9035b0..a7039aa 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -1025,7 +1025,7 @@ int MidiPlayer_Midi::open(ResourceManager *resMan) {
 						error("MT-32 patch has wrong type");
 					} else {
 						// Happens in the SCI3 interactive demo of Lighthouse
-						warning("TODO: Ignoring new SCI3 type of MT-32 patch for now (size = %lu)", res->size());
+						warning("TODO: Ignoring new SCI3 type of MT-32 patch for now (size = %u)", res->size());
 					}
 				}
 			} else {


Commit: cb4f06fb707a37a1cba4aa58d5b0567a530d6172
    https://github.com/scummvm/scummvm/commit/cb4f06fb707a37a1cba4aa58d5b0567a530d6172
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-03-30T14:23:41-05:00

Commit Message:
SCI: Avoid shadow warnings in old GCC

Changed paths:
    engines/sci/util.h


diff --git a/engines/sci/util.h b/engines/sci/util.h
index 1a054e1..edaa0ca 100644
--- a/engines/sci/util.h
+++ b/engines/sci/util.h
@@ -157,9 +157,9 @@ public:
 
 	inline SciSpanImpl(const pointer data_,
 					   const size_type size_,
-					   const Common::String &name = Common::String(),
-					   const size_type sourceByteOffset = 0) :
-		super_type(data_, size_, name, sourceByteOffset) {}
+					   const Common::String &name_ = Common::String(),
+					   const size_type sourceByteOffset_ = 0) :
+		super_type(data_, size_, name_, sourceByteOffset_) {}
 
 	template <typename Other>
 	inline SciSpanImpl(const Other &other) : super_type(other) {}
@@ -265,9 +265,9 @@ public:
 
 	inline SciSpan(const pointer data_,
 				   const size_type size_,
-				   const Common::String &name = Common::String(),
-				   const size_type sourceByteOffset = 0) :
-		super_type(data_, size_, name, sourceByteOffset) {}
+				   const Common::String &name_ = Common::String(),
+				   const size_type sourceByteOffset_ = 0) :
+		super_type(data_, size_, name_, sourceByteOffset_) {}
 
 	template <typename Other>
 	inline SciSpan(const Other &other) : super_type(other) {}





More information about the Scummvm-git-logs mailing list