Fix -Wunreachable-code-aggressive.

Bug: chromium:1066980
Change-Id: I9e00d3707972307e1c5395156c39aa153d5e170e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peter Kasting <pkasting@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
This commit is contained in:
Peter Kasting 2021-06-30 11:17:16 +00:00 committed by Dawn LUCI CQ
parent 0ecfece609
commit 1ce20bf5cf
6 changed files with 26 additions and 32 deletions

View File

@ -118,8 +118,6 @@ namespace dawn_wire { namespace server {
default:
return false;
}
return true;
}
}} // namespace dawn_wire::server

View File

@ -119,6 +119,7 @@ config("dawn_internal") {
"-Wshadow-field",
"-Wstrict-prototypes",
"-Wtautological-unsigned-zero-compare",
"-Wunreachable-code-aggressive",
]
if (is_win) {

View File

@ -105,7 +105,6 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR(
"The depth aspect of depth24plus texture cannot be selected in a "
"texture to buffer copy");
break;
case wgpu::TextureFormat::Depth32Float:
break;

View File

@ -368,12 +368,10 @@ namespace dawn_native {
if (HasOneBit(format.aspects)) {
Aspect single = format.aspects;
return single;
} else {
return DAWN_VALIDATION_ERROR(
"A single aspect must be selected for multi-planar formats in "
"texture <-> linear data copies");
}
break;
return DAWN_VALIDATION_ERROR(
"A single aspect must be selected for multi-planar formats in "
"texture <-> linear data copies");
case wgpu::TextureAspect::DepthOnly:
ASSERT(format.aspects & Aspect::Depth);
return Aspect::Depth;

View File

@ -784,7 +784,6 @@ namespace dawn_native {
}
case BindingInfoType::ExternalTexture: {
return DAWN_VALIDATION_ERROR("External textures are not supported.");
break;
}
}
}

View File

@ -50,12 +50,12 @@ namespace dawn_native {
#if defined(DAWN_ENABLE_BACKEND_METAL)
const SurfaceDescriptorFromMetalLayer* metalDesc = nullptr;
FindInChain(descriptor->nextInChain, &metalDesc);
if (!metalDesc) {
return DAWN_VALIDATION_ERROR("Unsupported sType");
}
// Check that the layer is a CAMetalLayer (or a derived class).
if (!InheritsFromCAMetalLayer(metalDesc->layer)) {
return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer");
if (metalDesc) {
// Check that the layer is a CAMetalLayer (or a derived class).
if (!InheritsFromCAMetalLayer(metalDesc->layer)) {
return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer");
}
return {};
}
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
@ -94,32 +94,31 @@ namespace dawn_native {
}
return {};
}
return DAWN_VALIDATION_ERROR("Unsupported sType");
#endif // defined(DAWN_PLATFORM_WINDOWS)
#if defined(DAWN_USE_X11)
const SurfaceDescriptorFromXlib* xDesc = nullptr;
FindInChain(descriptor->nextInChain, &xDesc);
if (!xDesc) {
return DAWN_VALIDATION_ERROR("Unsupported sType");
}
// Check the validity of the window by calling a getter function on the window that
// returns a status code. If the window is bad the call return a status of zero. We
// need to set a temporary X11 error handler while doing this because the default
// X11 error handler exits the program on any error.
XErrorHandler oldErrorHandler =
XSetErrorHandler([](Display*, XErrorEvent*) { return 0; });
XWindowAttributes attributes;
int status = XGetWindowAttributes(reinterpret_cast<Display*>(xDesc->display),
xDesc->window, &attributes);
XSetErrorHandler(oldErrorHandler);
if (xDesc) {
// Check the validity of the window by calling a getter function on the window that
// returns a status code. If the window is bad the call return a status of zero. We
// need to set a temporary X11 error handler while doing this because the default
// X11 error handler exits the program on any error.
XErrorHandler oldErrorHandler =
XSetErrorHandler([](Display*, XErrorEvent*) { return 0; });
XWindowAttributes attributes;
int status = XGetWindowAttributes(reinterpret_cast<Display*>(xDesc->display),
xDesc->window, &attributes);
XSetErrorHandler(oldErrorHandler);
if (status == 0) {
return DAWN_VALIDATION_ERROR("Invalid X Window");
if (status == 0) {
return DAWN_VALIDATION_ERROR("Invalid X Window");
}
return {};
}
#endif // defined(DAWN_USE_X11)
return {};
return DAWN_VALIDATION_ERROR("Unsupported sType");
}
Surface::Surface(InstanceBase* instance, const SurfaceDescriptor* descriptor)