<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 31/05/17 02:04, Ian Romanick wrote:<br>
    </div>
    <blockquote
      cite="mid:6ead1ca6-95bb-89d0-f4ae-0bb04e2712a2@freedesktop.org"
      type="cite">
      <pre wrap="">I've seen this warning a million times, and I always talk myself out of
fixing it.  If the type of counterIndex ever changes to int (or another
signed type), this will break.  It may not be obvious at the time of the
break that it happened, and it will likely be annoying to debug.

I'm not NAKing it, but it makes me nervous.  What do other folks think?</pre>
    </blockquote>
    <br>
    Spec says :<br>
    <br>
    "
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-wrap: break-word; white-space: pre-wrap;">Performance counter id 0
    is reserved as an invalid counter.

"
</pre>
    Maybe we should change counterid_to_index() to return a signed
    integer?<br>
    What are the chances to have more than 1^31 counters?<br>
    <br>
    <blockquote
      cite="mid:6ead1ca6-95bb-89d0-f4ae-0bb04e2712a2@freedesktop.org"
      type="cite">
      <pre wrap="">

On 05/30/2017 01:47 PM, Rob Herring wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Fixes the following warning:

external/mesa3d/src/mesa/main/performance_query.c:352:21: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
   if (counterIndex < 0 || counterIndex >= queryNumCounters) {
       ~~~~~~~~~~~~ ^ ~

counterIndex will be ~0 if invalid and the 2nd condition is sufficient to
catch that case.

Signed-off-by: Rob Herring <a class="moz-txt-link-rfc2396E" href="mailto:robh@kernel.org"><robh@kernel.org></a>
---
 src/mesa/main/performance_query.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/performance_query.c b/src/mesa/main/performance_query.c
index 56f6a7da8b9f..b9e7cf9961b5 100644
--- a/src/mesa/main/performance_query.c
+++ b/src/mesa/main/performance_query.c
@@ -349,7 +349,7 @@ _mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId,
 
    counterIndex = counterid_to_index(counterId);
 
-   if (counterIndex < 0 || counterIndex >= queryNumCounters) {
+   if (counterIndex >= queryNumCounters) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "glGetPerfCounterInfoINTEL(invalid counterId)");
       return;

</pre>
      </blockquote>
      <pre wrap="">
_______________________________________________
mesa-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>