Mesa (master): glsl: silence uninitialized var warning in read_texture()

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 25 12:12:01 PST 2011


Module: Mesa
Branch: master
Commit: 9f2bf3d65cf0745a34185c1966d52389fbd1ca90
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f2bf3d65cf0745a34185c1966d52389fbd1ca90

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jan 25 13:09:57 2011 -0700

glsl: silence uninitialized var warning in read_texture()

And generate an error if the texture pattern is not matched.

---

 src/glsl/ir_reader.cpp |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 0a2f743..b78aa05 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -876,7 +876,7 @@ ir_reader::read_texture(s_expression *expr)
    s_list *s_shadow = NULL;
    s_expression *s_lod = NULL;
 
-   ir_texture_opcode op;
+   ir_texture_opcode op = ir_tex; /* silence warning */
 
    s_pattern tex_pattern[] =
       { "tex", s_sampler, s_coord, s_offset, s_proj, s_shadow };
@@ -893,6 +893,9 @@ ir_reader::read_texture(s_expression *expr)
       op = ir_texture::get_opcode(tag->value());
       if (op == -1)
 	 return NULL;
+   } else {
+      ir_read_error(NULL, "unexpected texture pattern");
+      return NULL;
    }
 
    ir_texture *tex = new(mem_ctx) ir_texture(op);



More information about the mesa-commit mailing list