[Mesa-dev] [PATCH 1/1] clover: Use switch when creating kernel arguments
Francisco Jerez
currojerez at riseup.net
Thu Dec 4 04:21:54 PST 2014
Jan Vesely <jan.vesely at rutgers.edu> writes:
> This way we get a warning when an enum value is not handled
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> src/gallium/state_trackers/clover/core/kernel.cpp | 45 ++++++++++-------------
> 1 file changed, 20 insertions(+), 25 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
> index e07d14d..9ddc244 100644
> --- a/src/gallium/state_trackers/clover/core/kernel.cpp
> +++ b/src/gallium/state_trackers/clover/core/kernel.cpp
> @@ -293,38 +293,33 @@ namespace {
>
> std::unique_ptr<kernel::argument>
> kernel::argument::create(const module::argument &marg) {
> - if (marg.type == module::argument::scalar)
> - return std::unique_ptr<kernel::argument>(
> - new scalar_argument(marg.size));
> + switch(marg.type)
> + {
If you format the switch statement consistently, like:
| switch (marg.type) {
this patch is Reviewed-by: Francisco Jerez <currojerez at riseup.net>
> + case module::argument::scalar:
> + return std::unique_ptr<kernel::argument>(new scalar_argument(marg.size));
>
> - else if (marg.type == module::argument::global)
> - return std::unique_ptr<kernel::argument>(
> - new global_argument);
> + case module::argument::global:
> + return std::unique_ptr<kernel::argument>(new global_argument);
>
> - else if (marg.type == module::argument::local)
> - return std::unique_ptr<kernel::argument>(
> - new local_argument);
> + case module::argument::local:
> + return std::unique_ptr<kernel::argument>(new local_argument);
>
> - else if (marg.type == module::argument::constant)
> - return std::unique_ptr<kernel::argument>(
> - new constant_argument);
> + case module::argument::constant:
> + return std::unique_ptr<kernel::argument>(new constant_argument);
>
> - else if (marg.type == module::argument::image2d_rd ||
> - marg.type == module::argument::image3d_rd)
> - return std::unique_ptr<kernel::argument>(
> - new image_rd_argument);
> + case module::argument::image2d_rd:
> + case module::argument::image3d_rd:
> + return std::unique_ptr<kernel::argument>(new image_rd_argument);
>
> - else if (marg.type == module::argument::image2d_wr ||
> - marg.type == module::argument::image3d_wr)
> - return std::unique_ptr<kernel::argument>(
> - new image_wr_argument);
> + case module::argument::image2d_wr:
> + case module::argument::image3d_wr:
> + return std::unique_ptr<kernel::argument>(new image_wr_argument);
>
> - else if (marg.type == module::argument::sampler)
> - return std::unique_ptr<kernel::argument>(
> - new sampler_argument);
> + case module::argument::sampler:
> + return std::unique_ptr<kernel::argument>(new sampler_argument);
>
> - else
> - throw error(CL_INVALID_KERNEL_DEFINITION);
> + }
> + throw error(CL_INVALID_KERNEL_DEFINITION);
> }
>
> kernel::argument::argument() : _set(false) {
> --
> 1.9.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141204/85bd52f8/attachment-0001.sig>
More information about the mesa-dev
mailing list