Skip to content

Commit a90db24

Browse files
authored
Fix -Wunreachable-code-break findings in fbcode/executorch, xplat/executorch
Summary: D127334907 enables `-Wunreachable-code-break` through the PACKAGE files of `fbcode/example`, `fbcode/excalibur`, `fbcode/executorch`, `fbcode/experience-ai`, `xplat/executorch`. This diff fixes the code that warning flags there, so the PACKAGE change builds cleanly on top of it. Fixes the new warning in executorch (fbcode side edited; the `xplat/executorch` dirsync mirror is identical): removes `break;` statements that can never run because the preceding statement always leaves the case. In `devtools/bundled_program/bundled_program.cpp` they follow `ET_CHECK_OR_RETURN_ERROR(false, ...)` (always returns) or `return`; in `extension/fb/ptez/ptez_data_loader.cpp` and `runtime/executor/method_meta.cpp` (`get_tag`) they follow `return`; in `backends/vulkan/runtime/vk_api/Pipeline.cpp` (`vk_layout`) the inner `switch` returns on every path. Behavior is unchanged. Removes unreachable `break;` statements in Vulkan test and tool code (fbcode side edited; the `xplat/executorch` mirror is identical): `backends/vulkan/test/utils/test_utils.cpp` (after `throw`), `backends/vulkan/test/vulkan_compute_api_test.cpp` (after an inner `switch` that returns on every path), and `backends/vulkan/fb/tools/cli/{benchmark,correctness}/optparser.cpp` (after `exit(1)`). Reviewed By: dtolnay Differential Revision: D127368223 Pull Request resolved: pytorch#24155
1 parent 5b14a2f commit a90db24

5 files changed

Lines changed: 6 additions & 12 deletions

File tree

‎backends/vulkan/runtime/vk_api/Pipeline.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ VkImageLayout vk_layout(
8282
default:
8383
return VK_IMAGE_LAYOUT_GENERAL;
8484
}
85-
break;
8685
case PipelineStage::TRANSFER:
8786
switch (access) {
8887
case MemoryAccessType::READ:

‎backends/vulkan/test/utils/test_utils.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ void record_index_fill_buffer(api::Context* context, api::vTensor& v_ten) {
340340
break;
341341
default:
342342
throw std::runtime_error("Unsupported dtype");
343-
break;
344343
}
345344

346345
api::ParamsBuffer params(api::context(), int32_t(v_ten.numel()));

‎backends/vulkan/test/vulkan_compute_api_test.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ std::vector<int64_t> get_reference_strides(
292292
default:
293293
return {};
294294
}
295-
break;
296295
case utils::kHeightPacked:
297296
switch (sizes.size()) {
298297
case 1:

‎devtools/bundled_program/bundled_program.cpp‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ ET_NODISCARD Error load_bundled_input(
338338
NotSupported,
339339
"Data type %hhu not supported",
340340
static_cast<uint8_t>(bundled_input->val_type()));
341-
break;
342341
}
343342
}
344343

@@ -450,7 +449,6 @@ ET_NODISCARD ErrorStats compute_method_output_error_stats(
450449
"Data type %hhd not supported",
451450
static_cast<uint8_t>(bundled_expected_output->val_type()));
452451
return {Error::NotSupported, 0, 0, 0, 0};
453-
break; // Never reached
454452
}
455453
}
456454
}
@@ -532,7 +530,6 @@ ET_NODISCARD Error verify_method_outputs(
532530
NotSupported,
533531
"Data type %hhd not supported",
534532
static_cast<uint8_t>(bundled_expected_output->val_type()));
535-
break;
536533
}
537534
}
538535
}

‎runtime/executor/method_meta.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,22 @@ Result<Tag> get_tag(
9696
switch (serialization_value->val_type()) {
9797
case executorch_flatbuffer::KernelTypes::Null: {
9898
return Tag::None;
99-
} break;
99+
}
100100
case executorch_flatbuffer::KernelTypes::Int: {
101101
return Tag::Int;
102-
} break;
102+
}
103103
case executorch_flatbuffer::KernelTypes::Double: {
104104
return Tag::Double;
105-
} break;
105+
}
106106
case executorch_flatbuffer::KernelTypes::Bool: {
107107
return Tag::Bool;
108-
} break;
108+
}
109109
case executorch_flatbuffer::KernelTypes::String: {
110110
return Tag::String;
111-
} break;
111+
}
112112
case executorch_flatbuffer::KernelTypes::Tensor: {
113113
return Tag::Tensor;
114-
} break;
114+
}
115115
default:
116116
ET_LOG(
117117
Error,

0 commit comments

Comments
 (0)