Skip to content

Commit a9591f3

Browse files
committed
Merge pull request #66543 from akien-mga/msvc-warning-c4702
Fix MSVC warning C4702: unreachable code
2 parents 361d9b5 + 7ab0145 commit a9591f3

File tree

11 files changed

+34
-49
lines changed

11 files changed

+34
-49
lines changed

scene/gui/base_button.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool BaseButton::is_hovered() const {
264264
BaseButton::DrawMode BaseButton::get_draw_mode() const {
265265
if (status.disabled) {
266266
return DRAW_DISABLED;
267-
};
267+
}
268268

269269
if (!status.press_attempt && status.hovering) {
270270
if (status.pressed) {
@@ -273,8 +273,7 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
273273

274274
return DRAW_HOVER;
275275
} else {
276-
/* determine if pressed or not */
277-
276+
// Determine if pressed or not.
278277
bool pressing;
279278
if (status.press_attempt) {
280279
pressing = (status.pressing_inside || keep_pressed_outside);
@@ -291,8 +290,6 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
291290
return DRAW_NORMAL;
292291
}
293292
}
294-
295-
return DRAW_NORMAL;
296293
}
297294

298295
void BaseButton::set_toggle_mode(bool p_on) {

scene/gui/rich_text_label.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) co
5252
} else if (p_item->E->next()) {
5353
return p_item->E->next()->get();
5454
} else {
55-
//go up until something with a next is found
55+
// Go up until something with a next is found.
5656
while (p_item->parent && !p_item->E->next()) {
5757
p_item = p_item->parent;
5858
}
@@ -72,7 +72,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) co
7272
} else if (p_item->E->next()) {
7373
return p_item->E->next()->get();
7474
} else {
75-
//go up until something with a next is found
75+
// Go up until something with a next is found.
7676
while (p_item->type != ITEM_FRAME && !p_item->E->next()) {
7777
p_item = p_item->parent;
7878
}
@@ -84,8 +84,6 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) co
8484
}
8585
}
8686
}
87-
88-
return nullptr;
8987
}
9088

9189
RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) const {
@@ -97,7 +95,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) co
9795
} else if (p_item->E->prev()) {
9896
return p_item->E->prev()->get();
9997
} else {
100-
//go back until something with a prev is found
98+
// Go back until something with a prev is found.
10199
while (p_item->parent && !p_item->E->prev()) {
102100
p_item = p_item->parent;
103101
}
@@ -117,7 +115,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) co
117115
} else if (p_item->E->prev()) {
118116
return p_item->E->prev()->get();
119117
} else {
120-
//go back until something with a prev is found
118+
// Go back until something with a prev is found.
121119
while (p_item->type != ITEM_FRAME && !p_item->E->prev()) {
122120
p_item = p_item->parent;
123121
}
@@ -129,8 +127,6 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) co
129127
}
130128
}
131129
}
132-
133-
return nullptr;
134130
}
135131

136132
Rect2 RichTextLabel::_get_text_rect() {

scene/resources/animation.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,11 +2102,9 @@ bool Animation::track_is_compressed(int p_track) const {
21022102
return bst->compressed_track >= 0;
21032103
} break;
21042104
default: {
2105-
return false; //animation does not really use transitions
2105+
return false; // Animation does not really use transitions.
21062106
} break;
21072107
}
2108-
2109-
ERR_FAIL_V(false);
21102108
}
21112109

21122110
void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p_value) {

scene/resources/material.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,8 +3123,6 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value)
31233123
WARN_PRINT("Godot 3.x SpatialMaterial remapped parameter not found: " + String(p_name));
31243124
return true;
31253125
}
3126-
3127-
return false;
31283126
}
31293127

31303128
#endif // DISABLE_DEPRECATED

scene/resources/tile_set.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,6 @@ Vector<Point2> TileSet::get_terrain_polygon(int p_terrain_set) {
15371537
}
15381538
return _get_half_offset_terrain_polygon(tile_size, overlap, tile_offset_axis);
15391539
}
1540-
return Vector<Point2>();
15411540
}
15421541

15431542
Vector<Point2> TileSet::get_terrain_peering_bit_polygon(int p_terrain_set, TileSet::CellNeighbor p_bit) {

scene/resources/visual_shader_particle_nodes.cpp

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,31 +1130,38 @@ VisualShaderNodeParticleAccelerator::VisualShaderNodeParticleAccelerator() {
11301130
// VisualShaderNodeParticleOutput
11311131

11321132
String VisualShaderNodeParticleOutput::get_caption() const {
1133-
if (shader_type == VisualShader::TYPE_START) {
1134-
return "StartOutput";
1135-
} else if (shader_type == VisualShader::TYPE_PROCESS) {
1136-
return "ProcessOutput";
1137-
} else if (shader_type == VisualShader::TYPE_COLLIDE) {
1138-
return "CollideOutput";
1139-
} else if (shader_type == VisualShader::TYPE_START_CUSTOM) {
1140-
return "CustomStartOutput";
1141-
} else if (shader_type == VisualShader::TYPE_PROCESS_CUSTOM) {
1142-
return "CustomProcessOutput";
1133+
switch (shader_type) {
1134+
case VisualShader::TYPE_START:
1135+
return "StartOutput";
1136+
case VisualShader::TYPE_PROCESS:
1137+
return "ProcessOutput";
1138+
case VisualShader::TYPE_COLLIDE:
1139+
return "CollideOutput";
1140+
case VisualShader::TYPE_START_CUSTOM:
1141+
return "CustomStartOutput";
1142+
case VisualShader::TYPE_PROCESS_CUSTOM:
1143+
return "CustomProcessOutput";
1144+
default:
1145+
ERR_PRINT(vformat("Unexpected shader_type %d for VisualShaderNodeParticleOutput.", shader_type));
1146+
return "";
11431147
}
1144-
return String();
11451148
}
11461149

11471150
int VisualShaderNodeParticleOutput::get_input_port_count() const {
1148-
if (shader_type == VisualShader::TYPE_START) {
1149-
return 8;
1150-
} else if (shader_type == VisualShader::TYPE_COLLIDE) {
1151-
return 5;
1152-
} else if (shader_type == VisualShader::TYPE_START_CUSTOM || shader_type == VisualShader::TYPE_PROCESS_CUSTOM) {
1153-
return 6;
1154-
} else { // TYPE_PROCESS
1155-
return 7;
1151+
switch (shader_type) {
1152+
case VisualShader::TYPE_START:
1153+
return 8;
1154+
case VisualShader::TYPE_PROCESS:
1155+
return 7;
1156+
case VisualShader::TYPE_COLLIDE:
1157+
return 5;
1158+
case VisualShader::TYPE_START_CUSTOM:
1159+
case VisualShader::TYPE_PROCESS_CUSTOM:
1160+
return 6;
1161+
default:
1162+
ERR_PRINT(vformat("Unexpected shader_type %d for VisualShaderNodeParticleOutput.", shader_type));
1163+
return 0;
11561164
}
1157-
return 0;
11581165
}
11591166

11601167
VisualShaderNodeParticleOutput::PortType VisualShaderNodeParticleOutput::get_input_port_type(int p_port) const {

servers/physics_2d/godot_space_2d.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,6 @@ void *GodotSpace2D::_broadphase_pair(GodotCollisionObject2D *A, int p_subindex_A
10361036
GodotBodyPair2D *b = memnew(GodotBodyPair2D(static_cast<GodotBody2D *>(A), p_subindex_A, static_cast<GodotBody2D *>(B), p_subindex_B));
10371037
return b;
10381038
}
1039-
1040-
return nullptr;
10411039
}
10421040

10431041
void GodotSpace2D::_broadphase_unpair(GodotCollisionObject2D *A, int p_subindex_A, GodotCollisionObject2D *B, int p_subindex_B, void *p_data, void *p_self) {

servers/rendering/renderer_rd/environment/fog.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
122122
return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
123123
}
124124
}
125-
126-
return AABB();
127125
}
128126

129127
Vector3 Fog::fog_volume_get_extents(RID p_fog_volume) const {

servers/rendering/renderer_rd/renderer_scene_render_rd.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
282282
panorama->fill(panorama_color);
283283
return panorama;
284284
}
285-
286-
return Ref<Image>();
287285
}
288286

289287
////////////////////////////////////////////////////////////

servers/rendering/renderer_rd/storage_rd/particles_storage.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,8 +1874,6 @@ AABB ParticlesStorage::particles_collision_get_aabb(RID p_particles_collision) c
18741874
return aabb;
18751875
}
18761876
}
1877-
1878-
return AABB();
18791877
}
18801878

18811879
Vector3 ParticlesStorage::particles_collision_get_extents(RID p_particles_collision) const {

0 commit comments

Comments
 (0)