[Mesa-dev] [PATCH 2/4] compiler: avoid 'unused variable' and 'may be used uninitialized' warnings
asimiklit.work at gmail.com
asimiklit.work at gmail.com
Tue Sep 11 12:42:05 UTC 2018
From: Andrii Simiklit <andrii.simiklit at globallogic.com>
1. nir/nir_lower_vars_to_ssa.c:691:21: warning:
unused variable ‘var’
nir_variable *var = path->path[0]->var;
2. nir_types.cpp:558:31: warning:
‘elem_align’ may be used uninitialized in this function
unsigned elem_size, elem_align;
nir_types.cpp:558:20: warning:
‘elem_size’ may be used uninitialized in this function
unsigned elem_size, elem_align;
Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
---
src/compiler/nir/nir_lower_vars_to_ssa.c | 2 +-
src/compiler/nir_types.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c
index cd679be..96de261 100644
--- a/src/compiler/nir/nir_lower_vars_to_ssa.c
+++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
@@ -688,7 +688,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
nir_deref_path *path = &node->path;
assert(path->path[0]->deref_type == nir_deref_type_var);
- nir_variable *var = path->path[0]->var;
+ MAYBE_UNUSED nir_variable *var = path->path[0]->var;
/* We don't build deref nodes for non-local variables */
assert(var->data.mode == nir_var_local);
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index d24f094..d39d87b 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -542,7 +542,7 @@ glsl_get_natural_size_align_bytes(const struct glsl_type *type,
}
case GLSL_TYPE_ARRAY: {
- unsigned elem_size, elem_align;
+ unsigned elem_size = 0, elem_align = 0;
glsl_get_natural_size_align_bytes(type->fields.array,
&elem_size, &elem_align);
*align = elem_align;
@@ -554,7 +554,7 @@ glsl_get_natural_size_align_bytes(const struct glsl_type *type,
*size = 0;
*align = 0;
for (unsigned i = 0; i < type->length; i++) {
- unsigned elem_size, elem_align;
+ unsigned elem_size = 0, elem_align = 0;
glsl_get_natural_size_align_bytes(type->fields.structure[i].type,
&elem_size, &elem_align);
*align = MAX2(*align, elem_align);
--
2.7.4
More information about the mesa-dev
mailing list