[Mesa-dev] mesa/tnl_dd: Fix clang constant-logical-operand warnings.

Submitted by Vinson Lee on June 4, 2014, 11:48 p.m.

Details

Message ID 1401925711-9670-1-git-send-email-vlee@freedesktop.org
State New
Headers show

Not browsing as part of any series.

Commit Message

Vinson Lee June 4, 2014, 11:48 p.m.
This patch fixes these clang constant-logical-operand warnings.

../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:130:32: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
                               ^  ~~~~~~~~~~~
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:130:32: note: use '|' for a bitwise operation
   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
                               ^~
                               |
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:138:22: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
                     ^  ~~~~~~~~~~~
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:138:22: note: use '|' for a bitwise operation
      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
                     ^~
                     |
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:355:32: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
                               ^  ~~~~~~~~~~~
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:355:32: note: use '|' for a bitwise operation
   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
                               ^~
                               |
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:363:22: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
                     ^  ~~~~~~~~~~~
../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:363:22: note: use '|' for a bitwise operation
      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
                     ^~
                     |

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 src/mesa/tnl_dd/t_dd_tritmp.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h
index c1eb2de..8eccfca 100644
--- a/src/mesa/tnl_dd/t_dd_tritmp.h
+++ b/src/mesa/tnl_dd/t_dd_tritmp.h
@@ -127,7 +127,7 @@  static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint
    v[1] = (VERTEX *)GET_VERTEX(e1);
    v[2] = (VERTEX *)GET_VERTEX(e2);
 
-   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
+   if (DO_TWOSIDE | DO_OFFSET | DO_UNFILLED | DO_TWOSTENCIL)
    {
       GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
       GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
@@ -135,7 +135,7 @@  static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint
       GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
       GLfloat cc = ex*fy - ey*fx;
 
-      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
+      if (DO_TWOSIDE | DO_UNFILLED | DO_TWOSTENCIL)
       {
 	 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
 
@@ -352,7 +352,7 @@  static void TAG(quadr)( struct gl_context *ctx,
    v[2] = (VERTEX *)GET_VERTEX(e2);
    v[3] = (VERTEX *)GET_VERTEX(e3);
 
-   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
+   if (DO_TWOSIDE | DO_OFFSET | DO_UNFILLED | DO_TWOSTENCIL)
    {
       GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
       GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
@@ -360,7 +360,7 @@  static void TAG(quadr)( struct gl_context *ctx,
       GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
       GLfloat cc = ex*fy - ey*fx;
 
-      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
+      if (DO_TWOSIDE | DO_UNFILLED | DO_TWOSTENCIL)
       {
 	 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
 

Comments

Reviewed-by: Brian Paul <brianp@vmware.com>

But I think you could trim down the commit message to give just one example.


On 06/04/2014 04:48 PM, Vinson Lee wrote:
> This patch fixes these clang constant-logical-operand warnings.
>
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:130:32: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>     if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
>                                 ^  ~~~~~~~~~~~
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:130:32: note: use '|' for a bitwise operation
>     if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
>                                 ^~
>                                 |
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:138:22: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>        if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
>                       ^  ~~~~~~~~~~~
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:138:22: note: use '|' for a bitwise operation
>        if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
>                       ^~
>                       |
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:355:32: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>     if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
>                                 ^  ~~~~~~~~~~~
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:355:32: note: use '|' for a bitwise operation
>     if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
>                                 ^~
>                                 |
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:363:22: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>        if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
>                       ^  ~~~~~~~~~~~
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:363:22: note: use '|' for a bitwise operation
>        if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
>                       ^~
>                       |
>
> Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> ---
>   src/mesa/tnl_dd/t_dd_tritmp.h | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h
> index c1eb2de..8eccfca 100644
> --- a/src/mesa/tnl_dd/t_dd_tritmp.h
> +++ b/src/mesa/tnl_dd/t_dd_tritmp.h
> @@ -127,7 +127,7 @@ static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint
>      v[1] = (VERTEX *)GET_VERTEX(e1);
>      v[2] = (VERTEX *)GET_VERTEX(e2);
>
> -   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
> +   if (DO_TWOSIDE | DO_OFFSET | DO_UNFILLED | DO_TWOSTENCIL)
>      {
>         GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
>         GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
> @@ -135,7 +135,7 @@ static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint
>         GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
>         GLfloat cc = ex*fy - ey*fx;
>
> -      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
> +      if (DO_TWOSIDE | DO_UNFILLED | DO_TWOSTENCIL)
>         {
>   	 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
>
> @@ -352,7 +352,7 @@ static void TAG(quadr)( struct gl_context *ctx,
>      v[2] = (VERTEX *)GET_VERTEX(e2);
>      v[3] = (VERTEX *)GET_VERTEX(e3);
>
> -   if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
> +   if (DO_TWOSIDE | DO_OFFSET | DO_UNFILLED | DO_TWOSTENCIL)
>      {
>         GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
>         GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
> @@ -360,7 +360,7 @@ static void TAG(quadr)( struct gl_context *ctx,
>         GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
>         GLfloat cc = ex*fy - ey*fx;
>
> -      if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
> +      if (DO_TWOSIDE | DO_UNFILLED | DO_TWOSTENCIL)
>         {
>   	 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
>
>
On Wed, Jun 4, 2014 at 4:48 PM, Vinson Lee <vlee@freedesktop.org> wrote:
> This patch fixes these clang constant-logical-operand warnings.
>
> ../../../../../src/mesa/tnl_dd/t_dd_tritmp.h:130:32: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
>    if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
>                                ^  ~~~~~~~~~~~

Sorry about the warnings, but I think the code is fine as is. These
are supposed to be constant operands. Look at how the macros are
defined and used:

#define DO_TWOSIDE  (IND & R200_TWOSIDE_BIT)
...
#define IND (0)
#define TAG(x) x
#include "tnl_dd/t_dd_tritmp.h"

#define IND (R200_TWOSIDE_BIT)
#define TAG(x) x##_twoside
#include "tnl_dd/t_dd_tritmp.h"

If anything, you should modify the definition to something like

#define DO_TWOSIDE  ((IND & R200_TWOSIDE_BIT) != 0)

and hope clang doesn't complain, since they'll still be able to be
evaluated at compile time. Changing to bitwise operations isn't right.