[Scummvm-git-logs] scummvm master -> 975c23dfdf8c3fbf441062c298aa13195abc62c0

Strangerke noreply at scummvm.org
Mon Jun 23 21:19:27 UTC 2025


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

Summary:
975c23dfdf M4: Burger: Fix some PVS Studios issues


Commit: 975c23dfdf8c3fbf441062c298aa13195abc62c0
    https://github.com/scummvm/scummvm/commit/975c23dfdf8c3fbf441062c298aa13195abc62c0
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-23T22:19:13+01:00

Commit Message:
M4: Burger: Fix some PVS Studios issues

Changed paths:
    engines/m4/adv_r/adv_chk.h
    engines/m4/adv_r/conv_io.cpp
    engines/m4/burger/core/play_break.cpp
    engines/m4/burger/core/release_trigger.cpp
    engines/m4/burger/gui/gui_gizmo.cpp
    engines/m4/burger/rooms/section1/room101.cpp
    engines/m4/burger/rooms/section1/room102.cpp
    engines/m4/fileio/sys_file.h
    engines/m4/wscript/ws_load.cpp


diff --git a/engines/m4/adv_r/adv_chk.h b/engines/m4/adv_r/adv_chk.h
index a648e165b9c..6df725af272 100644
--- a/engines/m4/adv_r/adv_chk.h
+++ b/engines/m4/adv_r/adv_chk.h
@@ -23,7 +23,6 @@
 #ifndef M4_ADV_R_ADV_CHK_H
 #define M4_ADV_R_ADV_CHK_H
 
-#include "m4/m4_types.h"
 #include "m4/adv_r/adv.h"
 
 namespace M4 {
diff --git a/engines/m4/adv_r/conv_io.cpp b/engines/m4/adv_r/conv_io.cpp
index 4e80d76a174..319f08ee218 100644
--- a/engines/m4/adv_r/conv_io.cpp
+++ b/engines/m4/adv_r/conv_io.cpp
@@ -394,9 +394,7 @@ static void conv_save_state(Conv *c) {
 			// Append
 			offset = 0;
 
-			if (conv_save_buff)
-				mem_free(conv_save_buff);
-
+			mem_free(conv_save_buff);
 			conv_save_buff = (char *)mem_alloc(amt_to_write + NAME_SIZE + sizeof(int32), "conv save buff");
 			if (!conv_save_buff)
 				error_show(FL, 'OOM!');
diff --git a/engines/m4/burger/core/play_break.cpp b/engines/m4/burger/core/play_break.cpp
index 1583fdfa5df..0f0fcc96cda 100644
--- a/engines/m4/burger/core/play_break.cpp
+++ b/engines/m4/burger/core/play_break.cpp
@@ -22,7 +22,6 @@
 #include "m4/burger/core/play_break.h"
 #include "m4/platform/sound/digi.h"
 #include "m4/burger/vars.h"
-#include "m4/platform/sound/digi.h"
 #include "m4/graphics/gr_series.h"
 
 namespace M4 {
@@ -43,7 +42,7 @@ static void set_next_series_play_break(int32 slot) {
 			// Are the first and last frame numbers backwards?
 			if ((player->current_break.lastFrame != -1) && (player->current_break.firstFrame > player->current_break.lastFrame)) {
 				player->current_break.flags = player->current_break.flags | SERIES_BACKWARD;	// make sure SERIES_BACKWARD is in flags
-				int32 temp = player->current_break.firstFrame;									// switch the first and last frame numbers
+				const int32 temp = player->current_break.firstFrame;							// switch the first and last frame numbers
 				player->current_break.firstFrame = player->current_break.lastFrame;
 				player->current_break.lastFrame = temp;
 			}
@@ -137,7 +136,8 @@ int32 series_play_with_breaks(const seriesPlayBreak list[], const char *name, fr
 
 	// look for a free player slot (MAX_SERIES_PLAYERS)
 	for (slot = 0; slot < MAX_SERIES_PLAYERS; ++slot) {
-		if (!(_G(seriesPlayers)[slot].in_use))	break;
+		if (!(_G(seriesPlayers)[slot].in_use))
+			break;
 	}
 
 	if (slot >= MAX_SERIES_PLAYERS) {
diff --git a/engines/m4/burger/core/release_trigger.cpp b/engines/m4/burger/core/release_trigger.cpp
index 69d2395656a..a085652393e 100644
--- a/engines/m4/burger/core/release_trigger.cpp
+++ b/engines/m4/burger/core/release_trigger.cpp
@@ -32,18 +32,17 @@ void release_trigger_on_digi_state(int32 trigger, int32 checkChannels, int32 mat
 	_GT(check_channels) = checkChannels;
 	_GT(match_value) = matchValue;
 
-	KernelTriggerType oldMode = _G(kernel).trigger_mode;
+	const KernelTriggerType oldMode = _G(kernel).trigger_mode;
 	_G(kernel).trigger_mode = KT_DAEMON;
 	kernel_trigger_dispatch_now(kRELEASE_TRIGGER_DIGI_CHECK);
 	_G(kernel).trigger_mode = oldMode;
 }
 
 void release_trigger_digi_check() {
-	uint32 i;
 	uint32 digi_state = 0;
 
 	// Set channel bits in digi_state that a sound is presently busy in each channel
-	for (i = 0; i < 3; ++i) {
+	for (uint32 i = 0; i < 3; ++i) {
 		if (digi_play_state(i + 1))	 	// Check if a sound is playing
 			digi_state |= (1 << i); 	// Set the bit that corresponds with this channel 
 	}
diff --git a/engines/m4/burger/gui/gui_gizmo.cpp b/engines/m4/burger/gui/gui_gizmo.cpp
index ac48fb371c1..6627c9eda97 100644
--- a/engines/m4/burger/gui/gui_gizmo.cpp
+++ b/engines/m4/burger/gui/gui_gizmo.cpp
@@ -326,7 +326,7 @@ static void gizmo_daemon(int trigger) {
 
 static void gizmo_restore_interface(bool fade) {
 	if (_GIZMO(initialized)) {
-		_GIZMO(currentItem) = 0;
+		_GIZMO(currentItem) = nullptr;
 
 		if (_GIZMO(lowMemory2)) {
 			if (!adv_restoreBackground())
@@ -354,7 +354,7 @@ static void gizmo_dispose_gui() {
 		vmng_screen_dispose(_GIZMO(gui));
 		gizmo_free_gui(_GIZMO(gui));
 		gizmo_free_sprites();
-		_GIZMO(gui) = 0;
+		_GIZMO(gui) = nullptr;
 	}
 }
 
@@ -386,14 +386,12 @@ static bool gizmo_load_sprites(const char *name, size_t count) {
 		for (size_t idx = 0; idx < count; ++idx) {
 			_GIZMO(sprites)[idx] = CreateSprite(_GIZMO(seriesHandle), _GIZMO(celsOffset),
 				idx, nullptr, nullptr);
-			if (!_GIZMO(sprites)[idx])
-				return false;
 		}
 
 		return true;
-	} else {
-		return false;
 	}
+
+	return false;
 }
 
 static void gizmo_free_sprites() {
@@ -402,7 +400,7 @@ static void gizmo_free_sprites() {
 		mem_free(_GIZMO(assetName));
 
 		_GIZMO(assetName) = nullptr;
-		_GIZMO(seriesHandle) = 0;
+		_GIZMO(seriesHandle) = nullptr;
 		_GIZMO(celsOffset) = -1;
 		_GIZMO(palOffset) = -1;
 
@@ -497,8 +495,8 @@ static bool gizmo_eventHandler(void *s, int32 eventType, int32 event, int32 x, i
 		}
 	}
 
-	int xs = x + ctx->x1;
-	int ys = y + ctx->y1;
+	const int xs = x + ctx->x1;
+	const int ys = y + ctx->y1;
 
 	if (_GIZMO(currentItem)) {
 		flag = (*_GIZMO(currentItem)->_fnEvents)(_GIZMO(currentItem),
@@ -528,8 +526,7 @@ static bool gizmo_eventHandler(void *s, int32 eventType, int32 event, int32 x, i
 		}
 
 	} else if (eventType == EVENT_KEY) {
-		GizmoItem *item;
-		for (item = gizmo->_items; item && !flag; item = item->_next) {
+		for (GizmoItem *item = gizmo->_items; item && !flag; item = item->_next) {
 			if (item->_fnEvents)
 				flag = (*item->_fnEvents)(item, eventType, event, -1, -1, nullptr);
 		}
@@ -800,7 +797,8 @@ static GizmoItem *gizmo_add_item(Gizmo *gizmo, int id,
 
 	// Create new item
 	GizmoItem *item = (GizmoItem *)mem_alloc(sizeof(GizmoItem), "*gui gizmo item");
-	assert(item);
+	if (!item)
+		error("gizmo_add_item - Not enough emory to create item (%d bytes)", sizeof(GizmoItem));
 
 	// Put the new item at the head of the list
 	item->_next = gizmo->_items;
@@ -826,7 +824,8 @@ static GizmoItem *gizmo_add_item(Gizmo *gizmo, int id,
 	}
 
 	GizmoButton *btn = (GizmoButton *)mem_alloc(sizeof(GizmoButton), "*gizmo button");
-	assert(btn);
+	if (!btn)
+		error("gizmo_add_item - Not enough emory to create btn (%d bytes)", sizeof(GizmoButton));
 
 	btn->_state = selected ? SELECTED : NOTHING;
 	btn->_index = btnIndex;
diff --git a/engines/m4/burger/rooms/section1/room101.cpp b/engines/m4/burger/rooms/section1/room101.cpp
index c6868645f2d..5d7a353b7fd 100644
--- a/engines/m4/burger/rooms/section1/room101.cpp
+++ b/engines/m4/burger/rooms/section1/room101.cpp
@@ -550,6 +550,7 @@ void Room101::daemon() {
 			break;
 
 		case 11:
+		case 18:
 			door();
 			ws_unhide_walker(_G(my_walker));
 			player_set_commands_allowed(true);
@@ -587,12 +588,6 @@ void Room101::daemon() {
 			series_play("101ha01", 3840, 0, 1, 6, 0, 100, 0, 0, 0, 7);
 			break;
 
-		case 18:
-			door();
-			ws_unhide_walker(_G(my_walker));
-			player_set_commands_allowed(true);
-			break;
-
 		case 19:
 			_val2 = 13;
 			break;
diff --git a/engines/m4/burger/rooms/section1/room102.cpp b/engines/m4/burger/rooms/section1/room102.cpp
index 172806e2c55..3ebc7fc024c 100644
--- a/engines/m4/burger/rooms/section1/room102.cpp
+++ b/engines/m4/burger/rooms/section1/room102.cpp
@@ -460,7 +460,7 @@ void Room102::daemon() {
 					break;
 				}
 
-				if (++_val5 > 24 && _val5 != -666 && player_commands_allowed()) {
+				if (++_val5 > 24 && player_commands_allowed()) {
 					_val5 = -666;
 					conv_load_and_prepare("conv05", 20, false);
 					conv_export_pointer_curr(&_G(flags)[V016], 0);
@@ -875,9 +875,11 @@ void Room102::daemon() {
 		break;
 
 	case 19:
+	case 28:
 		player_set_commands_allowed(true);
 		break;
 
+
 	case 21:
 		if (_G(flags)[V013]) {
 			pal_fade_init(_G(kernel).first_fade, 255, 0, 30, 1001);
@@ -933,10 +935,6 @@ void Room102::daemon() {
 		}
 		break;
 
-	case 28:
-		player_set_commands_allowed(true);
-		break;
-
 	case 29:
 		if (_G(flags)[V012] != 2)
 			player_set_commands_allowed(true);
diff --git a/engines/m4/fileio/sys_file.h b/engines/m4/fileio/sys_file.h
index d47489713ff..78e2d814f09 100644
--- a/engines/m4/fileio/sys_file.h
+++ b/engines/m4/fileio/sys_file.h
@@ -113,7 +113,7 @@ public:
 	bool seek(uint32 pos);
 
 	/**
-	 * Seek ahaead by a given amount
+	 * Seek ahead by a given amount
 	 */
 	bool seek_ahead(int32 amount);
 
diff --git a/engines/m4/wscript/ws_load.cpp b/engines/m4/wscript/ws_load.cpp
index 3d3ab2248c4..f4e597431a2 100644
--- a/engines/m4/wscript/ws_load.cpp
+++ b/engines/m4/wscript/ws_load.cpp
@@ -518,7 +518,7 @@ M4sprite *CreateSprite(MemHandle resourceHandle, int32 handleOffset, int32 index
 	uint32 *celsPtr = (uint32 *)((intptr)*resourceHandle + handleOffset);
 
 	// Check that the index into the series requested is within a valid range
-	uint32 numCels = FROM_LE_32(celsPtr[CELS_COUNT]);
+	const uint32 numCels = FROM_LE_32(celsPtr[CELS_COUNT]);
 	if (index >= (int32)numCels) {
 		ws_LogErrorMsg(FL, "CreateSprite: Sprite index out of range - max index: %d, requested index: %d", numCels - 1, index);
 		return nullptr;




More information about the Scummvm-git-logs mailing list