diff options
author | Gert Wollny <[email protected]> | 2018-06-05 13:59:02 +0200 |
---|---|---|
committer | Gert Wollny <[email protected]> | 2018-06-20 11:08:28 +0200 |
commit | f79b9804862e61a93a60498d7360d991b332cb2c (patch) | |
tree | aa7e6f42a00859c112af69f7d27d11fad370a443 | |
parent | dc5ba7e17cf7395b3f3e444f03ef168a06cbdea8 (diff) |
gallium/aux/tgsi_two_side.c: Fix -Wsign-compare warnings
Integer propagation rules can sometimes be irritating. With
"unsigned x" "x + 1" gets propagated to a signed integer, so explicitely
assign the sum to an unsigned and use that for comaprison.
In file included from tgsi/tgsi_two_side.c:41:0:
tgsi/tgsi_two_side.c: In function 'xform_decl':
./util/u_math.h:660:29: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
^
tgsi/tgsi_two_side.c:86:24: note: in expansion of macro 'MAX2'
ts->num_inputs = MAX2(ts->num_inputs, decl->Range.Last + 1);
^~~~
./util/u_math.h:660:40: warning: signed and unsigned type in conditional
expression [-Wsign-compare]
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
^
tgsi/tgsi_two_side.c:86:24: note: in expansion of macro 'MAX2'
ts->num_inputs = MAX2(ts->num_inputs, decl->Range.Last + 1);
^~~~
./util/u_math.h:660:29: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
^
tgsi/tgsi_two_side.c:89:23: note: in expansion of macro 'MAX2'
ts->num_temps = MAX2(ts->num_temps, decl->Range.Last + 1);
^~~~
./util/u_math.h:660:40: warning: signed and unsigned type in conditional
expression [-Wsign-compare]
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
^
tgsi/tgsi_two_side.c:89:23: note: in expansion of macro 'MAX2'
ts->num_temps = MAX2(ts->num_temps, decl->Range.Last + 1);
^~~~
tgsi/tgsi_two_side.c: In function 'xform_inst':
tgsi/tgsi_two_side.c:184:45: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
if (inst->Src[i].Register.Index == ts-
>front_color_input[j]) {
^~
Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_two_side.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_two_side.c b/src/gallium/auxiliary/tgsi/tgsi_two_side.c index 2406e2876f3..53ac2a37003 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_two_side.c +++ b/src/gallium/auxiliary/tgsi/tgsi_two_side.c @@ -72,6 +72,7 @@ xform_decl(struct tgsi_transform_context *ctx, struct tgsi_full_declaration *decl) { struct two_side_transform_context *ts = two_side_transform_context(ctx); + unsigned range_end = decl->Range.Last + 1; if (decl->Declaration.File == TGSI_FILE_INPUT) { if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR) { @@ -83,10 +84,10 @@ xform_decl(struct tgsi_transform_context *ctx, else if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) { ts->face_input = decl->Range.First; } - ts->num_inputs = MAX2(ts->num_inputs, decl->Range.Last + 1); + ts->num_inputs = MAX2(ts->num_inputs, range_end); } else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) { - ts->num_temps = MAX2(ts->num_temps, decl->Range.Last + 1); + ts->num_temps = MAX2(ts->num_temps, range_end); } ctx->emit_declaration(ctx, decl); @@ -181,7 +182,7 @@ xform_inst(struct tgsi_transform_context *ctx, for (i = 0; i < info->num_src; i++) { if (inst->Src[i].Register.File == TGSI_FILE_INPUT) { for (j = 0; j < 2; j++) { - if (inst->Src[i].Register.Index == ts->front_color_input[j]) { + if (inst->Src[i].Register.Index == (int)ts->front_color_input[j]) { /* replace color input with temp reg */ inst->Src[i].Register.File = TGSI_FILE_TEMPORARY; inst->Src[i].Register.Index = ts->new_colors[j]; |