[Mesa-dev] [PATCH] nv50: use larger arrays to silence warnings

Jose Fonseca jfonseca at vmware.com
Wed Feb 1 02:40:22 PST 2012


Silences warnings and fixes potential bugs due to buffer overflow.

The nv50 maintainers could benefit from sprinkling a few asserts to catch this early in the future, as it is  bound to happen again.

Jose

----- Original Message -----
> The warnings were:
> nv50_pc_regalloc.c: In function ‘pass_generate_phi_movs’:
> nv50_pc_regalloc.c:423:41: warning: array subscript is above array
> bounds
> codegen/nv50_ir_peephole.cpp: In member function ‘bool
> nv50_ir::MemoryOpt::replaceStFromSt(nv50_ir::Instruction*,
> nv50_ir::MemoryOpt::Record*)’:
> codegen/nv50_ir_peephole.cpp:1475:18: warning: array subscript is
> above array bounds
> codegen/nv50_ir_peephole.cpp:1475:18: warning: array subscript is
> above array bounds
> codegen/nv50_ir_peephole.cpp:1475:18: warning: array subscript is
> above array bounds
> codegen/nv50_ir_peephole.cpp:1475:18: warning: array subscript is
> above array bounds
> ---
>  .../drivers/nv50/codegen/nv50_ir_peephole.cpp      |    2 +-
>  src/gallium/drivers/nv50/nv50_pc.h                 |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
> b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
> index fc025d8..fb4041f 100644
> --- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
> @@ -1463,7 +1463,7 @@ MemoryOpt::replaceStFromSt(Instruction
> *restrict st, Record *rec)
>     st->takeExtraSources(0, extra);
>  
>     if (offR < offS) {
> -      Value *vals[4];
> +      Value *vals[10];
>        int s, n;
>        int k = 0;
>        // get non-replaced sources of ri
> diff --git a/src/gallium/drivers/nv50/nv50_pc.h
> b/src/gallium/drivers/nv50/nv50_pc.h
> index 45804d3..9abefa2 100644
> --- a/src/gallium/drivers/nv50/nv50_pc.h
> +++ b/src/gallium/drivers/nv50/nv50_pc.h
> @@ -234,7 +234,7 @@ struct nv_instruction {
>     int serial;
>     struct nv_value *def[4];
>     struct nv_value *flags_def;
> -   struct nv_ref *src[5];
> +   struct nv_ref *src[6];
>     struct nv_ref *flags_src;
>     struct nv_basic_block *bb;
>     struct nv_basic_block *target; /* target block of control flow
>     insn */
> --
> 1.7.3.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list