[Scummvm-git-logs] scummvm master -> 941be4f4c0a738a3fa1e3c6b7f80a734667775e6

digitall 547637+digitall at users.noreply.github.com
Wed May 20 13:51:46 UTC 2020


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

Summary:
941be4f4c0 PETKA: Fix Invalid Test Due to Unsigned Variable


Commit: 941be4f4c0a738a3fa1e3c6b7f80a734667775e6
    https://github.com/scummvm/scummvm/commit/941be4f4c0a738a3fa1e3c6b7f80a734667775e6
Author: D G Turner (digitall at scummvm.org)
Date: 2020-05-20T14:46:29+01:00

Commit Message:
PETKA: Fix Invalid Test Due to Unsigned Variable

This triggered a GCC compiler warning that the test was always false
due to variable range. The _items.size() returns an unsigned variable.
This is not automatically promoted to signed by the subtraction, so
the result will still never be less than zero.

To avoid this, we can reorder the test to avoid the subtraction which
is more readable anyway.

Changed paths:
    engines/petka/objects/object_case.cpp


diff --git a/engines/petka/objects/object_case.cpp b/engines/petka/objects/object_case.cpp
index c4dfa9f600..385599f754 100644
--- a/engines/petka/objects/object_case.cpp
+++ b/engines/petka/objects/object_case.cpp
@@ -206,7 +206,7 @@ void QObjectCase::removeItem(int id) {
 		}
 	}
 
-	_itemIndex = _items.size() - 6 < 0 ? 0 : _items.size() - 6;
+	_itemIndex = (_items.size() < 6) ? 0 : (_items.size() - 6);
 
 	if (_isShown) {
 		show(0);




More information about the Scummvm-git-logs mailing list