[Mesa-dev] [PATCH 2/2] mesa: Always return a value in _mesa_format_from_format_and_type

Jason Ekstrand jason at jlekstrand.net
Mon May 4 05:52:21 PDT 2015


On May 4, 2015 4:25 AM, "Iago Toral Quiroga" <itoral at igalia.com> wrote:
>
> Return MESA_FORMAT_NONE if no matching type was found. We have an
> assertion here, but we should return something anyway to avoid
> confusion with non-debug builds.
> ---
>  src/mesa/main/glformats.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
> index 8ced579..fddd048 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -2752,4 +2752,5 @@ _mesa_format_from_format_and_type(GLenum format,
GLenum type)
>      * format in that case.
>      */
>     unreachable("Unsupported format");
> +   return MESA_FORMAT_NONE;

If we want this to have well-defined results, this should not be an
unreachable().  The semantics of unreachable allow the compiler to generate
wrong code for the case where it does get reached.  We could switch it to
an assert or we could just drop this patch. I'd be a fan of the latter.
--Jason

>  }
> --
> 1.9.1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150504/a5ee826e/attachment.html>


More information about the mesa-dev mailing list