Mesa (master): r300/compiler: Silence uninitialized variable warning.
Vinson Lee
vlee at kemper.freedesktop.org
Wed Aug 25 06:09:55 UTC 2010
Module: Mesa
Branch: master
Commit: 0ae6b30c147e6a237cd4e6338975e46de5a95565
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ae6b30c147e6a237cd4e6338975e46de5a95565
Author: Vinson Lee <vlee at vmware.com>
Date: Tue Aug 24 23:04:20 2010 -0700
r300/compiler: Silence uninitialized variable warning.
The variable loops would be used uninitialized if it ever processed a
RC_OPCODE_ENDLOOP case first.
This patch initalizes the loops variable to NULL and adds an assert at
the RC_OPCODE_ENDLOOP case that loops isn't NULL.
Silence the following GCC warning.
r3xx_vertprog.c: In function 'translate_vertex_program':
r3xx_vertprog.c:469: warning: 'loops' may be used uninitialized in this function
---
src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
index 997c091..5086d76 100644
--- a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
+++ b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
@@ -466,7 +466,7 @@ static void translate_vertex_program(struct r300_vertex_program_compiler * compi
{
struct rc_instruction *rci;
- struct loop * loops;
+ struct loop * loops = NULL;
int current_loop_depth = 0;
int loops_reserved = 0;
@@ -559,10 +559,16 @@ static void translate_vertex_program(struct r300_vertex_program_compiler * compi
}
case RC_OPCODE_ENDLOOP:
{
- struct loop * l = &loops[current_loop_depth - 1];
- unsigned int act_addr = l->BgnLoop - 1;
- unsigned int last_addr = (compiler->code->length / 4) - 1;
- unsigned int ret_addr = l->BgnLoop;
+ struct loop * l;
+ unsigned int act_addr;
+ unsigned int last_addr;
+ unsigned int ret_addr;
+
+ assert(loops);
+ l = &loops[current_loop_depth - 1];
+ act_addr = l->BgnLoop - 1;
+ last_addr = (compiler->code->length / 4) - 1;
+ ret_addr = l->BgnLoop;
if (loops_reserved >= R300_VS_MAX_FC_OPS) {
rc_error(&compiler->Base,
More information about the mesa-commit
mailing list