[Mesa-dev] [PATCH] Fix warnings.

Romain Failliot romain.failliot at foolstep.com
Sun May 29 11:54:06 UTC 2016


Can now compile with -Werror.

Fixed -Wunused-variable, -Wunused-but-set-variable, -Wmaybe-uninitialized
and -Wunused-function.

To prevent warnings for variables only used in asserts, I void them right
after the call to assert().
---
 src/compiler/spirv/vtn_variables.c             | 1 +
 src/gallium/drivers/softpipe/sp_state_shader.c | 2 ++
 src/gallium/drivers/svga/svga_swtnl_draw.c     | 1 +
 src/gallium/drivers/svga/svga_tgsi_insn.c      | 1 +
 src/mesa/drivers/dri/i965/brw_eu_emit.c        | 1 +
 src/mesa/drivers/dri/i965/gen8_draw_upload.c   | 2 ++
 src/mesa/state_tracker/st_glsl_to_nir.cpp      | 7 ++++---
 7 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 812ac62..0e8aa05 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -938,6 +938,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
          location += VARYING_SLOT_VAR0;
       } else {
          assert(!"Location must be on input or output variable");
+         is_vertex_input = false;
       }
 
       if (nir_var) {
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 38673d8..1f0a50c 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -424,6 +424,8 @@ softpipe_delete_compute_state(struct pipe_context *pipe,
    struct sp_compute_shader *state = (struct sp_compute_shader *)cs;
 
    assert(softpipe->cs != state);
+   (void) softpipe;
+
    tgsi_free_tokens(state->tokens);
    FREE(state);
 }
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index 67d1fae..8ed54dc 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -112,6 +112,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
 
    /* Ensure the draw module didn't touch this */
    assert(old_num_vertex_buffers == svga->curr.num_vertex_buffers);
+   (void) old_num_vertex_buffers;
 
    /*
     * unmap vertex/index buffers
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index a7fa6a2..0e20013 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -669,6 +669,7 @@ submit_op4(struct svga_shader_emitter *emit,
     * in one slot at least:
     */
    assert(type1 == SVGA3DREG_SAMPLER);
+   (void) type1;
 
    if (type0 == SVGA3DREG_CONST &&
        ((type3 == SVGA3DREG_CONST && src0.base.num != src3.base.num) ||
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 1c2ccb4..6baf0b8 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -2252,6 +2252,7 @@ gen7_block_read_scratch(struct brw_codegen *p,
    const struct brw_device_info *devinfo = p->devinfo;
    brw_inst *insn = next_insn(p, BRW_OPCODE_SEND);
    assert(brw_inst_pred_control(devinfo, insn) == BRW_PREDICATE_NONE);
+   (void) devinfo;
 
    brw_set_dest(p, insn, retype(dest, BRW_REGISTER_TYPE_UW));
 
diff --git a/src/mesa/drivers/dri/i965/gen8_draw_upload.c b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
index 5b3f673..7c592fa 100644
--- a/src/mesa/drivers/dri/i965/gen8_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
@@ -34,6 +34,7 @@
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 
+#ifndef NDEBUG
 static bool
 is_passthru_format(uint32_t format)
 {
@@ -47,6 +48,7 @@ is_passthru_format(uint32_t format)
       return false;
    }
 }
+#endif /* !NDEBUG */
 
 static void
 gen8_emit_vertices(struct brw_context *brw)
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 98c075f..4b5f6b4 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -168,10 +168,11 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
          continue;
 
       if (uniform->type->is_sampler()) {
-         unsigned val;
-         bool found = shader_program->UniformHash->get(val, uniform->name);
+         unsigned val = 0;
+         if (!shader_program->UniformHash->get(val, uniform->name)) {
+             assert(0);
+         }
          loc = shaderidx++;
-         assert(found);
          /* this ensure that nir_lower_samplers looks at the correct
           * shader_program->UniformStorage[location]:
           */
-- 
2.5.5



More information about the mesa-dev mailing list