From: Jan Vesely Date: Sat, 6 Dec 2014 00:05:30 +0000 (-0500) Subject: clover: Use switch when creating kernel arguments. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a18fc60581ad27811b0b4b22fce51da0ae8a008;p=mesa.git clover: Use switch when creating kernel arguments. This way we get a warning if an enum value is not handled. v2: codestyle Signed-off-by: Jan Vesely Reviewed-by: Francisco Jerez --- diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index e07d14d39f7..442762c4773 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -293,38 +293,32 @@ namespace { std::unique_ptr kernel::argument::create(const module::argument &marg) { - if (marg.type == module::argument::scalar) - return std::unique_ptr( - new scalar_argument(marg.size)); + switch (marg.type) { + case module::argument::scalar: + return std::unique_ptr(new scalar_argument(marg.size)); - else if (marg.type == module::argument::global) - return std::unique_ptr( - new global_argument); + case module::argument::global: + return std::unique_ptr(new global_argument); - else if (marg.type == module::argument::local) - return std::unique_ptr( - new local_argument); + case module::argument::local: + return std::unique_ptr(new local_argument); - else if (marg.type == module::argument::constant) - return std::unique_ptr( - new constant_argument); + case module::argument::constant: + return std::unique_ptr(new constant_argument); - else if (marg.type == module::argument::image2d_rd || - marg.type == module::argument::image3d_rd) - return std::unique_ptr( - new image_rd_argument); + case module::argument::image2d_rd: + case module::argument::image3d_rd: + return std::unique_ptr(new image_rd_argument); - else if (marg.type == module::argument::image2d_wr || - marg.type == module::argument::image3d_wr) - return std::unique_ptr( - new image_wr_argument); + case module::argument::image2d_wr: + case module::argument::image3d_wr: + return std::unique_ptr(new image_wr_argument); - else if (marg.type == module::argument::sampler) - return std::unique_ptr( - new sampler_argument); + case module::argument::sampler: + return std::unique_ptr(new sampler_argument); - else - throw error(CL_INVALID_KERNEL_DEFINITION); + } + throw error(CL_INVALID_KERNEL_DEFINITION); } kernel::argument::argument() : _set(false) {