Module: Mesa
Branch: main
Commit: d446ccfc81bc985e592949bc440fbd6709ecf737
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d446ccfc81bc985e592949bc440fbd6709ecf737

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Oct 24 09:16:25 2023 -0400

draw: fix uninit variable false positive

In function ‘generate_clipmask’,
    inlined from ‘draw_llvm_generate’ at 
../src/gallium/auxiliary/draw/draw_llvm.c:1975:24:
../src/gallium/auxiliary/draw/draw_llvm.c:1302:25: warning: ‘sum’ may be used 
uninitialized [-Wmaybe-uninitialized]
 1302 |                   sum = lp_build_fmuladd(builder, planes,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1303 |                                          (LLVMValueRef[]){cv_x, cv_y, 
cv_z, cv_w}[i], sum);
      |                                          
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/gallium/auxiliary/draw/draw_llvm.c: In function ‘draw_llvm_generate’:
../src/gallium/auxiliary/draw/draw_llvm.c:1149:44: note: ‘sum’ was declared here
 1149 |    LLVMValueRef plane1, planes, plane_ptr, sum;
      |                                            ^~~

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25884>

---

 src/gallium/auxiliary/draw/draw_llvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 3516fce6325..f4e0d70cd32 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1146,7 +1146,7 @@ generate_clipmask(struct draw_llvm *llvm,
    LLVMValueRef zero, shift;
    LLVMValueRef pos_x, pos_y, pos_z, pos_w;
    LLVMValueRef cv_x, cv_y, cv_z, cv_w;
-   LLVMValueRef plane1, planes, plane_ptr, sum;
+   LLVMValueRef plane1, planes, plane_ptr;
    struct lp_type f32_type = vs_type;
    struct lp_type i32_type = lp_int_type(vs_type);
    const unsigned pos = llvm->draw->vs.position_output;
@@ -1287,6 +1287,7 @@ generate_clipmask(struct draw_llvm *llvm,
          } else {
             LLVMTypeRef vs_elem_type = lp_build_elem_type(gallivm, vs_type);
             LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type);
+            LLVMValueRef sum = NULL;
             indices[0] = lp_build_const_int32(gallivm, 0);
             indices[1] = lp_build_const_int32(gallivm, plane_idx);
 

Reply via email to