[virglrenderer-devel] [PATCH 12/21] vrend_shader.c: Fix warnings

Gert Wollny gert.wollny at collabora.com
Fri Jun 1 08:47:59 UTC 2018


vrend_shader.c: In function »iter_declaration«:
vrend_shader.c:341:27: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
       if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
                           ^
vrend_shader.c:372:39: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
                   if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
                                       ^
vrend_shader.c:389:42: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
                      if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
                                          ^
vrend_shader.c:549:28: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
       if (ctx->num_outputs > ARRAY_SIZE(ctx->outputs)) {
                            ^
vrend_shader.c:755:27: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
          if (ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) {
                           ^~
vrend_shader.c:775:34: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
       if (ctx->num_system_values > ARRAY_SIZE(ctx->system_values)) {
                                  ^
vrend_shader.c: In function »iter_immediate«:
vrend_shader.c:875:14: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
    if (first >= ARRAY_SIZE(ctx->imm)) {
              ^~
vrend_shader.c: In function »prepare_so_movs«:
vrend_shader.c:1030:18: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
    for (i = 0; i < ctx->so->num_outputs; i++) {
                  ^
vrend_shader.c: In function »emit_so_movs«:
vrend_shader.c:1063:18: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
    for (i = 0; i < ctx->so->num_outputs; i++) {
                  ^
vrend_shader.c: In function »translate_tex«:
vrend_shader.c:1253:19: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
    if (sreg_index >= ARRAY_SIZE(ctx->samplers)) {
                   ^~
vrend_shader.c:1567:37: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
       if (inst->TexOffsets[0].Index >= ARRAY_SIZE(ctx->imm)) {
                                     ^~
vrend_shader.c: In function »iter_instruction«:
vrend_shader.c:1814:39: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
             if (ctx->outputs[j].first == dst->Register.Index) {
                                       ^~
vrend_shader.c:1903:38: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
             if (ctx->inputs[j].first == src->Register.Index) {
                                      ^~
vrend_shader.c:2014:34: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
          if (src->Register.Index >= ARRAY_SIZE(ctx->imm)) {
                                  ^~
vrend_shader.c:2094:45: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
             if (ctx->system_values[j].first == src->Register.Index) {
                                             ^~
vrend_shader.c: In function »get_aux_string«:
vrend_shader.c:2712:60: Warning: unused parameter »cfg« [-Wunused-
parameter]
 static const char *get_aux_string(struct vrend_shader_cfg *cfg, bool
centroid)
                                                            ^~~
vrend_shader.c:2717:19: Warning: qualifier of return type ignored
 [-Wignored-qualifiers]
 static const char get_return_type_prefix(enum tgsi_return_type type)
                   ^~~~~~~~~~~~~~~~~~~~~~
vrend_shader.c: In function »emit_ios«:
vrend_shader.c:2935:21: Warning: comparison between signed and unsigned
integer expressions[-Wsign-compare]
       for (i = 0; i < ctx->so->num_outputs; i++) {

vrend_shader.c: In function ‘get_destination_info’:
vrend_shader.c:1819:33: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
          for (uint32_t j = 0; j < ctx->num_outputs; j++) {
                                 ^
vrend_shader.c: In function ‘get_source_info’:
vrend_shader.c:1940:33: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
          for (uint32_t j = 0; j < ctx->num_inputs; j++)
                                 ^
vrend_shader.c:2129:33: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
          for (uint32_t j = 0; j < ctx->num_system_values; j++)
                                 ^

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/vrend_shader.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 19e5a4b..e78a48f 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -62,7 +62,7 @@ struct vrend_shader_io {
    unsigned                done;
    int                        sid;
    unsigned                interpolate;
-   unsigned first;
+   int first;
    bool                 centroid;
    bool                    invariant;
    bool glsl_predefined_no_emit;
@@ -389,7 +389,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
    switch (decl->Declaration.File) {
    case TGSI_FILE_INPUT:
       i = ctx->num_inputs++;
-      if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
+      if ((uint)ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
          fprintf(stderr, "Number of inputs exceeded, max is %lu\n", ARRAY_SIZE(ctx->inputs));
          return FALSE;
       }
@@ -420,7 +420,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
             } else {
                if (ctx->key->color_two_side) {
                   int j = ctx->num_inputs++;
-                  if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
+                  if ((uint)ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
                      fprintf(stderr, "Number of inputs exceeded, max is %lu\n", ARRAY_SIZE(ctx->inputs));
                      return FALSE;
                   }
@@ -437,7 +437,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
 
                   if (ctx->front_face_emitted == false) {
                      int k = ctx->num_inputs++;
-                     if (ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
+                     if ((uint)ctx->num_inputs > ARRAY_SIZE(ctx->inputs)) {
                         fprintf(stderr, "Number of inputs exceeded, max is %lu\n", ARRAY_SIZE(ctx->inputs));
                         return FALSE;
                      }
@@ -597,7 +597,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
       break;
    case TGSI_FILE_OUTPUT:
       i = ctx->num_outputs++;
-      if (ctx->num_outputs > ARRAY_SIZE(ctx->outputs)) {
+      if ((uint)ctx->num_outputs > ARRAY_SIZE(ctx->outputs)) {
          fprintf(stderr, "Number of outputs exceeded, max is %lu\n", ARRAY_SIZE(ctx->outputs));
          return FALSE;
       }
@@ -803,7 +803,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
       break;
    case TGSI_FILE_CONSTANT:
       if (decl->Declaration.Dimension) {
-         if (ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) {
+         if ((uint)ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) {
             fprintf(stderr, "Number of uniforms exceeded, max is %lu\n", ARRAY_SIZE(ctx->ubo_idx));
             return FALSE;
          }
@@ -823,7 +823,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
       break;
    case TGSI_FILE_SYSTEM_VALUE:
       i = ctx->num_system_values++;
-      if (ctx->num_system_values > ARRAY_SIZE(ctx->system_values)) {
+      if ((uint)ctx->num_system_values > ARRAY_SIZE(ctx->system_values)) {
          fprintf(stderr, "Number of system values exceeded, max is %lu\n", ARRAY_SIZE(ctx->system_values));
          return FALSE;
       }
@@ -923,7 +923,7 @@ iter_immediate(
    int i;
    int first = ctx->num_imm;
 
-   if (first >= ARRAY_SIZE(ctx->imm)) {
+   if ((uint)first >= ARRAY_SIZE(ctx->imm)) {
       fprintf(stderr, "Number of immediates exceeded, max is: %lu\n", ARRAY_SIZE(ctx->imm));
       return FALSE;
    }
@@ -1077,7 +1077,7 @@ static int emit_prescale(struct dump_ctx *ctx)
 
 static int prepare_so_movs(struct dump_ctx *ctx)
 {
-   int i;
+   uint i;
    for (i = 0; i < ctx->so->num_outputs; i++) {
       ctx->write_so_outputs[i] = true;
       if (ctx->so->output[i].start_component != 0)
@@ -1101,7 +1101,7 @@ static int prepare_so_movs(struct dump_ctx *ctx)
 static int emit_so_movs(struct dump_ctx *ctx)
 {
    char buf[255];
-   int i, j;
+   uint i, j;
    char outtype[15] = {0};
    char writemask[6];
    char *sret;
@@ -1301,7 +1301,7 @@ static int translate_tex(struct dump_ctx *ctx,
    int sampler_index;
    const char *tex_ext;
 
-   if (sreg_index >= ARRAY_SIZE(ctx->samplers)) {
+   if ((uint)sreg_index >= ARRAY_SIZE(ctx->samplers)) {
       fprintf(stderr, "Sampler view exceeded, max is %lu\n", ARRAY_SIZE(ctx->samplers));
       return FALSE;
    }
@@ -1615,7 +1615,7 @@ static int translate_tex(struct dump_ctx *ctx,
    }
 
    if (inst->Texture.NumOffsets == 1) {
-      if (inst->TexOffsets[0].Index >= ARRAY_SIZE(ctx->imm)) {
+      if ((uint)inst->TexOffsets[0].Index >= ARRAY_SIZE(ctx->imm)) {
          fprintf(stderr, "Immediate exceeded, max is %lu\n", ARRAY_SIZE(ctx->imm));
          return false;
       }
@@ -1816,7 +1816,7 @@ get_destination_info(struct dump_ctx *ctx,
       }
 
       if (dst_reg->Register.File == TGSI_FILE_OUTPUT) {
-         for (uint32_t j = 0; j < ctx->num_outputs; j++) {
+         for (int j = 0; j < ctx->num_outputs; j++) {
             if (ctx->outputs[j].first == dst_reg->Register.Index) {
                if (ctx->glsl_ver_required >= 140 && ctx->outputs[j].name == TGSI_SEMANTIC_CLIPVERTEX) {
                   snprintf(dsts[i], 255, "clipv_tmp");
@@ -1937,7 +1937,7 @@ get_source_info(struct dump_ctx *ctx,
          swizzle[swz_idx++] = get_swiz_char(src->Register.SwizzleW);
       }
       if (src->Register.File == TGSI_FILE_INPUT) {
-         for (uint32_t j = 0; j < ctx->num_inputs; j++)
+         for (int j = 0; j < ctx->num_inputs; j++)
             if (ctx->inputs[j].first == src->Register.Index) {
                if (ctx->key->color_two_side && ctx->inputs[j].name == TGSI_SEMANTIC_COLOR)
                   snprintf(srcs[i], 255, "%s(%s%s%d%s%s)", get_string(stypeprefix), prefix, "realcolor", ctx->inputs[j].sid, arrayname, swizzle);
@@ -2047,7 +2047,7 @@ get_source_info(struct dump_ctx *ctx,
          }
          *sreg_index = src->Register.Index;
       } else if (src->Register.File == TGSI_FILE_IMMEDIATE) {
-         if (src->Register.Index >= ARRAY_SIZE(ctx->imm)) {
+         if ((uint)src->Register.Index >= ARRAY_SIZE(ctx->imm)) {
             fprintf(stderr, "Immediate exceeded, max is %lu\n", ARRAY_SIZE(ctx->imm));
             return false;
          }
@@ -2126,7 +2126,7 @@ get_source_info(struct dump_ctx *ctx,
             }
          }
       } else if (src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
-         for (uint32_t j = 0; j < ctx->num_system_values; j++)
+         for (int j = 0; j < ctx->num_system_values; j++)
             if (ctx->system_values[j].first == src->Register.Index) {
                if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID ||
                    ctx->system_values[j].name == TGSI_SEMANTIC_INSTANCEID ||
@@ -2795,10 +2795,11 @@ static const char *get_interp_string(struct vrend_shader_cfg *cfg, int interpola
 
 static const char *get_aux_string(struct vrend_shader_cfg *cfg, bool centroid)
 {
+   VREND_UNUSED(cfg);
    return centroid ? "centroid " : "";
 }
 
-static const char get_return_type_prefix(enum tgsi_return_type type)
+static char get_return_type_prefix(enum tgsi_return_type type)
 {
    if (type == TGSI_RETURN_TYPE_SINT)
       return 'i';
@@ -3016,7 +3017,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
 
    if (ctx->so) {
       char outtype[6] = {0};
-      for (i = 0; i < ctx->so->num_outputs; i++) {
+      for (i = 0; i < (int)ctx->so->num_outputs; i++) {
          if (!ctx->write_so_outputs[i])
             continue;
          if (ctx->so->output[i].num_components == 1)
-- 
2.17.0



More information about the virglrenderer-devel mailing list