[Mesa-dev] [PATCH v2 2/2] gallivm: Fix trivial sign warnings
Jose Fonseca
jfonseca at vmware.com
Sat Jun 11 16:38:19 UTC 2016
On 10/06/16 04:01, Jan Vesely wrote:
> From: Jan Vesely <jan.vesely at rutgers.edu>
>
> v2: include whitespace fixes
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> src/gallium/auxiliary/gallivm/lp_bld_conv.c | 4 ++--
> src/gallium/auxiliary/gallivm/lp_bld_logic.c | 10 ++++++----
> src/gallium/auxiliary/gallivm/lp_bld_pack.c | 2 +-
> src/gallium/auxiliary/gallivm/lp_bld_printf.c | 7 +++----
> src/gallium/auxiliary/gallivm/lp_bld_swizzle.c | 2 +-
> src/gallium/auxiliary/gallivm/lp_bld_tgsi.c | 6 +++---
> src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 +-
> src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 10 +++++-----
> 8 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
> index 7cf0dee..69d24a5 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
> @@ -311,7 +311,7 @@ lp_build_clamped_float_to_unsigned_norm(struct gallivm_state *gallivm,
> * important, we also get exact results for 0.0 and 1.0.
> */
>
> - unsigned n = MIN2(src_type.width - 1, dst_width);
> + unsigned n = MIN2(src_type.width - 1u, dst_width);
>
> double scale = (double)(1ULL << n);
> unsigned lshift = dst_width - n;
> @@ -445,7 +445,7 @@ int lp_build_conv_auto(struct gallivm_state *gallivm,
> unsigned num_srcs,
> LLVMValueRef *dst)
> {
> - int i;
> + unsigned i;
> int num_dsts = num_srcs;
>
> if (src_type.floating == dst_type->floating &&
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
> index a26cc48..14bf236 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
> @@ -88,8 +88,6 @@ lp_build_compare_ext(struct gallivm_state *gallivm,
> LLVMValueRef cond;
> LLVMValueRef res;
>
> - assert(func >= PIPE_FUNC_NEVER);
> - assert(func <= PIPE_FUNC_ALWAYS);
> assert(lp_check_value(type, a));
> assert(lp_check_value(type, b));
>
> @@ -98,6 +96,9 @@ lp_build_compare_ext(struct gallivm_state *gallivm,
> if(func == PIPE_FUNC_ALWAYS)
> return ones;
>
> + assert(func > PIPE_FUNC_NEVER);
> + assert(func < PIPE_FUNC_ALWAYS);
> +
> if(type.floating) {
> LLVMRealPredicate op;
> switch(func) {
> @@ -176,8 +177,6 @@ lp_build_compare(struct gallivm_state *gallivm,
> LLVMValueRef zeros = LLVMConstNull(int_vec_type);
> LLVMValueRef ones = LLVMConstAllOnes(int_vec_type);
>
> - assert(func >= PIPE_FUNC_NEVER);
> - assert(func <= PIPE_FUNC_ALWAYS);
> assert(lp_check_value(type, a));
> assert(lp_check_value(type, b));
>
> @@ -186,6 +185,9 @@ lp_build_compare(struct gallivm_state *gallivm,
> if(func == PIPE_FUNC_ALWAYS)
> return ones;
>
> + assert(func > PIPE_FUNC_NEVER);
> + assert(func < PIPE_FUNC_ALWAYS);
> +
> #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
> /*
> * There are no unsigned integer comparison instructions in SSE.
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
> index 35b4c58..b0e76e6 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
> @@ -236,7 +236,7 @@ lp_build_concat_n(struct gallivm_state *gallivm,
> unsigned num_dsts)
> {
> int size = num_srcs / num_dsts;
> - int i;
> + unsigned i;
>
> assert(num_srcs >= num_dsts);
> assert((num_srcs % size) == 0);
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> index 14131b3..575ebdf 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
> @@ -155,10 +155,10 @@ lp_build_print_value(struct gallivm_state *gallivm,
> }
>
>
> -static int
> +static unsigned
> lp_get_printf_arg_count(const char *fmt)
> {
> - int count =0;
> + unsigned count = 0;
> const char *p = fmt;
> int c;
>
> @@ -195,8 +195,7 @@ lp_build_printf(struct gallivm_state *gallivm,
> {
> LLVMValueRef params[50];
> va_list arglist;
> - int argcount;
> - int i;
> + unsigned argcount, i;
>
> argcount = lp_get_printf_arg_count(fmt);
> assert(ARRAY_SIZE(params) >= argcount + 1);
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
> index 92f387d..5a97c48 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
> @@ -467,7 +467,7 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
> LLVMValueRef res;
> struct lp_type type4;
> unsigned cond = 0;
> - unsigned chan;
> + int chan;
> int shift;
>
> /*
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
> index 614c655..3f5bfec 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
> @@ -335,7 +335,7 @@ lp_build_emit_fetch(
> enum tgsi_opcode_type stype = tgsi_opcode_infer_src_type(inst->Instruction.Opcode);
>
> if (chan_index == LP_CHAN_ALL) {
> - swizzle = ~0;
> + swizzle = ~0u;
> } else {
> swizzle = tgsi_util_get_full_src_register_swizzle(reg, chan_index);
> if (swizzle > 3) {
> @@ -398,7 +398,7 @@ lp_build_emit_fetch(
> * Swizzle the argument
> */
>
> - if (swizzle == ~0) {
> + if (swizzle == ~0u) {
> res = bld_base->emit_swizzle(bld_base, res,
> reg->Register.SwizzleX,
> reg->Register.SwizzleY,
> @@ -453,7 +453,7 @@ lp_build_emit_fetch_texoffset(
> * Swizzle the argument
> */
>
> - if (swizzle == ~0) {
> + if (swizzle == ~0u) {
> res = bld_base->emit_swizzle(bld_base, res,
> off->SwizzleX,
> off->SwizzleY,
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
> index b9094dc..de1150c 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
> @@ -52,7 +52,7 @@
> extern "C" {
> #endif
>
> -#define LP_CHAN_ALL ~0
> +#define LP_CHAN_ALL ~0u
>
> #define LP_MAX_INSTRUCTIONS 256
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> index 31157a8..2897c92 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> @@ -642,7 +642,7 @@ static boolean default_analyse_is_last(struct lp_exec_mask *mask,
> {
> unsigned pc = bld_base->pc;
> struct function_ctx *ctx = func_ctx(mask);
> - unsigned curr_switch_stack = ctx->switch_stack_size;
> + int curr_switch_stack = ctx->switch_stack_size;
>
> if (ctx->switch_stack_size > LP_MAX_TGSI_NESTING) {
> return false;
> @@ -653,7 +653,7 @@ static boolean default_analyse_is_last(struct lp_exec_mask *mask,
> pc++;
> }
>
> - while (pc != -1 && pc < bld_base->num_instructions) {
> + while (pc != ~0u && pc < bld_base->num_instructions) {
> unsigned opcode = bld_base->instructions[pc].Instruction.Opcode;
> switch (opcode) {
> case TGSI_OPCODE_CASE:
> @@ -856,7 +856,7 @@ static void lp_exec_mask_endsub(struct lp_exec_mask *mask, int *pc)
> static LLVMValueRef
> get_file_ptr(struct lp_build_tgsi_soa_context *bld,
> unsigned file,
> - unsigned index,
> + int index,
> unsigned chan)
> {
> LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
> @@ -1227,7 +1227,7 @@ emit_fetch_constant(
> LLVMValueRef res;
>
> /* XXX: Handle fetching xyzw components as a vector */
> - assert(swizzle != ~0);
> + assert(swizzle != ~0u);
>
> if (reg->Register.Dimension) {
> assert(!reg->Dimension.Indirect);
> @@ -2882,7 +2882,7 @@ emit_dump_file(struct lp_build_tgsi_soa_context *bld,
> int chan;
>
> if (index < 8 * sizeof(unsigned) &&
> - (info->file_mask[file] & (1 << index)) == 0) {
> + (info->file_mask[file] & (1u << index)) == 0) {
> /* This was not declared.*/
> continue;
> }
>
Looks good to me.
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
More information about the mesa-dev
mailing list