Module: Mesa Branch: master Commit: 520521e3809a36201582fa48ee173eba12e97812 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=520521e3809a36201582fa48ee173eba12e97812
Author: Dylan Noblesmith <nob...@dreamwidth.org> Date: Sun Apr 1 18:35:29 2012 +0000 util: fix uninitialized table Most of the 256 values in the 'generic_to_slot' table were supposed to be initialized with the default value 0xff, but were left at zero (from CALLOC_STRUCT()) instead. Noticed by clang: u_linkage.h:60:31: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess] memset(table, 0xff, sizeof(table)); ~~~~~ ^~~~~ Also fix a signed/unsigned comparison and a comment typo here. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Brian Paul <bri...@vmware.com> --- src/gallium/auxiliary/util/u_linkage.h | 9 +++++---- src/gallium/drivers/nvfx/nvfx_fragprog.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_linkage.h b/src/gallium/auxiliary/util/u_linkage.h index 43ec917..7b23123 100644 --- a/src/gallium/auxiliary/util/u_linkage.h +++ b/src/gallium/auxiliary/util/u_linkage.h @@ -49,15 +49,16 @@ unsigned util_semantic_set_from_program_file(struct util_semantic_set *set, cons * * num_slots is the size of the layout array and hardware limit instead. * - * efficient_slots == 0 or efficient_solts == num_slots are typical settings. + * efficient_slots == 0 or efficient_slots == num_slots are typical settings. */ void util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots); static INLINE void -util_semantic_table_from_layout(unsigned char *table, unsigned char *layout, unsigned char first_slot_value, unsigned char num_slots) +util_semantic_table_from_layout(unsigned char *table, size_t table_size, unsigned char *layout, + unsigned char first_slot_value, unsigned char num_slots) { - int i; - memset(table, 0xff, sizeof(table)); + unsigned char i; + memset(table, 0xff, table_size); for(i = 0; i < num_slots; ++i) table[layout[i]] = first_slot_value + i; diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c index dbd7c77..0babcbb 100644 --- a/src/gallium/drivers/nvfx/nvfx_fragprog.c +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c @@ -977,7 +977,8 @@ nvfx_fragprog_prepare(struct nvfx_context* nvfx, struct nvfx_fpc *fpc) if(fpc->fp->num_slots > num_texcoords) return FALSE; util_semantic_layout_from_set(fpc->fp->slot_to_generic, &set, 0, num_texcoords); - util_semantic_table_from_layout(fpc->generic_to_slot, fpc->fp->slot_to_generic, 0, num_texcoords); + util_semantic_table_from_layout(fpc->generic_to_slot, sizeof fpc->generic_to_slot, + fpc->fp->slot_to_generic, 0, num_texcoords); memset(fpc->fp->slot_to_fp_input, 0xff, sizeof(fpc->fp->slot_to_fp_input)); _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit