[1/2] mesa: Fix clang build error w/ util_blitter_get_color_format_for_zs()

Message ID 20190703231038.73097-1-john.stultz@linaro.org
State New
Headers show
Series
  • [1/2] mesa: Fix clang build error w/ util_blitter_get_color_format_for_zs()
Related show

Commit Message

John Stultz July 3, 2019, 11:10 p.m.
Building with clang, I'm seeing
 u_blitter.h:627:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]

The util_blitter_get_color_format_for_zs() asserts for any
unhandled types, so we do not expect to reach the end of the
function here.

But provide a dummy return with an explicit assert above
to ensure we don't hit it with any future changes to the logic.

Cc: Rob Clark <robdclark@chromium.org>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Greg Hartman <ghartman@google.com>
Cc: Tapani Pälli <tapani.palli@intel.com>
Cc: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 src/gallium/auxiliary/util/u_blitter.h | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.17.1

Comments

Marek Olšák July 4, 2019, 3:45 a.m. | #1
Thanks for the notice. I had already had a fix for this, but forgot to push
it. It's pushed now.

Marek

On Wed, Jul 3, 2019 at 7:10 PM John Stultz <john.stultz@linaro.org> wrote:

> Building with clang, I'm seeing

>  u_blitter.h:627:1: error: control may reach end of non-void function

> [-Werror,-Wreturn-type]

>

> The util_blitter_get_color_format_for_zs() asserts for any

> unhandled types, so we do not expect to reach the end of the

> function here.

>

> But provide a dummy return with an explicit assert above

> to ensure we don't hit it with any future changes to the logic.

>

> Cc: Rob Clark <robdclark@chromium.org>

> Cc: Emil Velikov <emil.l.velikov@gmail.com>

> Cc: Amit Pundir <amit.pundir@linaro.org>

> Cc: Sumit Semwal <sumit.semwal@linaro.org>

> Cc: Alistair Strachan <astrachan@google.com>

> Cc: Greg Hartman <ghartman@google.com>

> Cc: Tapani Pälli <tapani.palli@intel.com>

> Cc: Marek Olšák <marek.olsak@amd.com>

> Signed-off-by: John Stultz <john.stultz@linaro.org>

> ---

>  src/gallium/auxiliary/util/u_blitter.h | 3 +++

>  1 file changed, 3 insertions(+)

>

> diff --git a/src/gallium/auxiliary/util/u_blitter.h

> b/src/gallium/auxiliary/util/u_blitter.h

> index 9e3fa55e648..7d6c3db64da 100644

> --- a/src/gallium/auxiliary/util/u_blitter.h

> +++ b/src/gallium/auxiliary/util/u_blitter.h

> @@ -624,6 +624,9 @@ util_blitter_get_color_format_for_zs(enum pipe_format

> format)

>     default:

>        assert(0);

>     }

> +   assert(0);

> +   /*XXX NEVER GET HERE*/

> +   return PIPE_FORMAT_R32G32_UINT;

>  }

>

>  #ifdef __cplusplus

> --

> 2.17.1

>

> _______________________________________________

> dri-devel mailing list

> dri-devel@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/dri-devel
<div dir="ltr"><div>Thanks for the notice. I had already had a fix for this, but forgot to push it. It&#39;s pushed now.</div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 3, 2019 at 7:10 PM John Stultz &lt;<a href="mailto:john.stultz@linaro.org">john.stultz@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Building with clang, I&#39;m seeing<br>
 u_blitter.h:627:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]<br>
<br>
The util_blitter_get_color_format_for_zs() asserts for any<br>
unhandled types, so we do not expect to reach the end of the<br>
function here.<br>
<br>
But provide a dummy return with an explicit assert above<br>
to ensure we don&#39;t hit it with any future changes to the logic.<br>
<br>
Cc: Rob Clark &lt;<a href="mailto:robdclark@chromium.org" target="_blank">robdclark@chromium.org</a>&gt;<br>
Cc: Emil Velikov &lt;<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>&gt;<br>
Cc: Amit Pundir &lt;<a href="mailto:amit.pundir@linaro.org" target="_blank">amit.pundir@linaro.org</a>&gt;<br>
Cc: Sumit Semwal &lt;<a href="mailto:sumit.semwal@linaro.org" target="_blank">sumit.semwal@linaro.org</a>&gt;<br>
Cc: Alistair Strachan &lt;<a href="mailto:astrachan@google.com" target="_blank">astrachan@google.com</a>&gt;<br>
Cc: Greg Hartman &lt;<a href="mailto:ghartman@google.com" target="_blank">ghartman@google.com</a>&gt;<br>
Cc: Tapani Pälli &lt;<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>&gt;<br>
Cc: Marek Olšák &lt;<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>&gt;<br>
Signed-off-by: John Stultz &lt;<a href="mailto:john.stultz@linaro.org" target="_blank">john.stultz@linaro.org</a>&gt;<br>

---<br>
 src/gallium/auxiliary/util/u_blitter.h | 3 +++<br>
 1 file changed, 3 insertions(+)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h<br>
index 9e3fa55e648..7d6c3db64da 100644<br>
--- a/src/gallium/auxiliary/util/u_blitter.h<br>
+++ b/src/gallium/auxiliary/util/u_blitter.h<br>
@@ -624,6 +624,9 @@ util_blitter_get_color_format_for_zs(enum pipe_format format)<br>
    default:<br>
       assert(0);<br>
    }<br>
+   assert(0);<br>
+   /*XXX NEVER GET HERE*/<br>
+   return PIPE_FORMAT_R32G32_UINT;<br>
 }<br>
<br>
 #ifdef __cplusplus<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a></blockquote></div>

Patch

diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 9e3fa55e648..7d6c3db64da 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -624,6 +624,9 @@  util_blitter_get_color_format_for_zs(enum pipe_format format)
    default:
       assert(0);
    }
+   assert(0);
+   /*XXX NEVER GET HERE*/
+   return PIPE_FORMAT_R32G32_UINT;
 }
 
 #ifdef __cplusplus