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

Strangerke noreply at scummvm.org
Thu Jun 19 21:44:09 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:
d13ebf393a M4: fix a couple of warning concerning useless assignations, simplify some switches, reduce variable scopes in conv_io.c


Commit: d13ebf393a2cab4fd004d481e75dd7f2d1856da3
    https://github.com/scummvm/scummvm/commit/d13ebf393a2cab4fd004d481e75dd7f2d1856da3
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-19T22:43:54+01:00

Commit Message:
M4: fix a couple of warning concerning useless assignations, simplify some switches, reduce variable scopes in conv_io.cpp

Changed paths:
    engines/m4/adv_r/conv_io.cpp


diff --git a/engines/m4/adv_r/conv_io.cpp b/engines/m4/adv_r/conv_io.cpp
index c2af6d2880a..4e80d76a174 100644
--- a/engines/m4/adv_r/conv_io.cpp
+++ b/engines/m4/adv_r/conv_io.cpp
@@ -132,10 +132,9 @@ int32 conv_current_entry() {
 }
 
 void conv_reset(const char *filename) {
-	Conv *c = nullptr;
 	_GC(restore_conv) = 0;
 
-	c = conv_load(filename, 1, 1, -1, false);
+	Conv *c = conv_load(filename, 1, 1, -1, false);
 	conv_unload(c);
 }
 
@@ -198,17 +197,12 @@ void conv_export_value(Conv *c, int32 val, int index) {
 	while (ent < c->chunkSize) {
 		conv_ops_get_entry(ent, &next, &tag, c);
 
-		switch (tag) {
-		case DECL_CHUNK:
+		if (tag == DECL_CHUNK) {
 			if (i == index) {
 				decl_chunk *decl = get_decl(c, ent);
 				conv_set_decl_val(c, decl, val);
 			}
 			i++;
-			break;
-
-		default:
-			break;
 		}
 		ent = next;
 	}
@@ -393,8 +387,8 @@ static void conv_save_state(Conv *c) {
 
 		if (offset != -1) {
 			overwrite_file = true;
-			int32 prev_size = READ_LE_UINT32(&conv_save_buff[offset]);
-			prev_size += NAME_SIZE + sizeof(int32);
+			/* int32 prev_size = */ READ_LE_UINT32(&conv_save_buff[offset]);
+			/* prev_size += NAME_SIZE + sizeof(int32);*/
 			offset += sizeof(int32);	// Skip header. (name + size)
 		} else {
 			// Append
@@ -450,8 +444,8 @@ static void conv_save_state(Conv *c) {
 	ent = 0;
 	c->myCNode = 0;
 
-	int32 val = 0;
-	entry_chunk *entry = nullptr;
+	int32 val;
+	entry_chunk *entry;
 
 	while (ent < c->chunkSize) {
 		conv_ops_get_entry(ent, &next, &tag, c);
@@ -464,7 +458,6 @@ static void conv_save_state(Conv *c) {
 
 			WRITE_LE_UINT32(&conv_save_buff[offset], val);
 			offset += sizeof(int32);
-
 			size += sizeof(int32);
 			break;
 
@@ -500,11 +493,11 @@ static void conv_save_state(Conv *c) {
 	// Copy the flags
 	if (flag_index != 0) {
 		WRITE_LE_UINT32(&conv_save_buff[offset], e_flags);
-		offset += sizeof(int32);
+		// offset += sizeof(int32);
 		size += sizeof(int32);
 	}
 
-	if ((amt_to_write != size))
+	if (amt_to_write != size)
 		error_show(FL, 'CNVS', "save_state: error! size written != size (%d %d)", amt_to_write, size);
 
 	// Finally, write out the conversation data
@@ -527,9 +520,6 @@ static void conv_save_state(Conv *c) {
 static Conv *conv_restore_state(Conv *c) {
 	int32 tag, next;
 
-	entry_chunk *entry;
-	decl_chunk *decl;
-
 	short flag_index = 0;
 	int32 val;
 	int32 e_flags = 0;
@@ -538,7 +528,7 @@ static Conv *conv_restore_state(Conv *c) {
 	char fname[13];
 	int file_size;
 
-	int32 ent = 0;
+	int32 ent;
 	c->myCNode = 0;
 
 	find_and_set_conv_name(c);
@@ -583,17 +573,12 @@ static Conv *conv_restore_state(Conv *c) {
 	while (ent < c->chunkSize) {
 		conv_ops_get_entry(ent, &next, &tag, c);
 
-		switch (tag) {
-		case DECL_CHUNK:
+		if (tag == DECL_CHUNK) {
 			val = READ_LE_UINT32(&conv_save_buff[offset]);
 			offset += sizeof(int32);
-			decl = get_decl(c, ent);
+			decl_chunk *decl = get_decl(c, ent);
 
 			conv_set_decl_val(c, decl, val);
-			break;
-
-		default:
-			break;
 		}
 
 		ent = next;
@@ -605,13 +590,8 @@ static Conv *conv_restore_state(Conv *c) {
 	while (ent < c->chunkSize) {
 		conv_ops_get_entry(ent, &next, &tag, c);
 
-		switch (tag) {
-		case LNODE_CHUNK:
-		case NODE_CHUNK:
-			break;
-
-		case ENTRY_CHUNK:
-			entry = get_entry(c, ent);
+		if (tag == ENTRY_CHUNK) {
+			entry_chunk *entry = get_entry(c, ent);
 
 			if (flag_index == 32) {
 				flag_index = 0;
@@ -627,10 +607,6 @@ static Conv *conv_restore_state(Conv *c) {
 			entry->status = val;
 
 			flag_index += 4;
-			break;
-
-		default:
-			break;
 		}
 
 		ent = next;
@@ -832,8 +808,7 @@ void conv_unload() {
 // only called if node is visible.
 // gets the TEXT chunks inside a node.
 int conv_get_text(int32 offset, int32 size, Conv *c) {
-	int32 i = offset, tag, next, text_len, text_width;
-	text_chunk *text;
+	int32 i = offset, tag, next;
 	int	result = 0;
 
 	size -= sizeof(entry_chunk);
@@ -841,25 +816,21 @@ int conv_get_text(int32 offset, int32 size, Conv *c) {
 	while (i < offset + size) {
 		conv_ops_get_entry(i, &next, &tag, c);
 
-		switch (tag) {
-		case TEXT_CHUNK:
+		if (tag == TEXT_CHUNK) {
 			result = 1;
-			text = get_text(c, i);
+			text_chunk *text = get_text(c, i);
 			assert(text);
-			text_len = conv_ops_text_strlen(get_string(c, c->myCNode + i + sizeof(text_chunk)));
+			const int32 text_len = conv_ops_text_strlen(get_string(c, c->myCNode + i + sizeof(text_chunk)));
 			_G(cdd).snd_files[_G(cdd).num_txt_ents] = get_string(c, c->myCNode + i + sizeof(text_chunk));
 			_G(cdd).text[_G(cdd).num_txt_ents] = get_string(c, c->myCNode + i + sizeof(text_chunk) + text_len);
 
-			text_width = gr_font_string_width(_G(cdd).text[_G(cdd).num_txt_ents], 1);
+			const int32 text_width = gr_font_string_width(_G(cdd).text[_G(cdd).num_txt_ents], 1);
 			if (text_width > _GC(width))
 				_GC(width) = text_width;
 
 			_G(cdd).num_txt_ents++;
-			break;
-
-		default:
-			break;
 		}
+
 		i = next;
 	}
 	return result;




More information about the Scummvm-git-logs mailing list