diff --git a/generator/templates/dawn_wire/server/ServerDoers.cpp b/generator/templates/dawn_wire/server/ServerDoers.cpp index 7a705770d7..0c3031cffc 100644 --- a/generator/templates/dawn_wire/server/ServerDoers.cpp +++ b/generator/templates/dawn_wire/server/ServerDoers.cpp @@ -118,8 +118,6 @@ namespace dawn_wire { namespace server { default: return false; } - - return true; } }} // namespace dawn_wire::server diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn index dd76c2a83e..e34df57104 100644 --- a/src/common/BUILD.gn +++ b/src/common/BUILD.gn @@ -119,6 +119,7 @@ config("dawn_internal") { "-Wshadow-field", "-Wstrict-prototypes", "-Wtautological-unsigned-zero-compare", + "-Wunreachable-code-aggressive", ] if (is_win) { diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index 507c3b1b67..1c1cd720c5 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -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; diff --git a/src/dawn_native/CommandValidation.cpp b/src/dawn_native/CommandValidation.cpp index 65c8743b7c..a5b054387d 100644 --- a/src/dawn_native/CommandValidation.cpp +++ b/src/dawn_native/CommandValidation.cpp @@ -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; diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 8a07a59f6a..4a05cb1db8 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -784,7 +784,6 @@ namespace dawn_native { } case BindingInfoType::ExternalTexture: { return DAWN_VALIDATION_ERROR("External textures are not supported."); - break; } } } diff --git a/src/dawn_native/Surface.cpp b/src/dawn_native/Surface.cpp index ba398fca95..5da7bdd498 100644 --- a/src/dawn_native/Surface.cpp +++ b/src/dawn_native/Surface.cpp @@ -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(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(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)