[Mesa-dev] [PATCH v2 3/3] ac/nir: assert printfs will fit

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Wed Jun 28 19:22:48 UTC 2017


Thanks, pushed patches 2& 3.

On Mon, Jun 26, 2017 at 10:05 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> Patches 2 & 3:
>
> Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
>
> On 23.06.2017 12:18, James Legg wrote:
>>
>> ---
>>   src/amd/common/ac_nir_to_llvm.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/amd/common/ac_nir_to_llvm.c
>> b/src/amd/common/ac_nir_to_llvm.c
>> index 3a26668..b32a9f5 100644
>> --- a/src/amd/common/ac_nir_to_llvm.c
>> +++ b/src/amd/common/ac_nir_to_llvm.c
>> @@ -1134,7 +1134,9 @@ static LLVMValueRef emit_intrin_1f_param(struct
>> nir_to_llvm_context *ctx,
>>                 to_float(ctx, src0),
>>         };
>>   -     sprintf(name, "%s.f%d", intrin, get_elem_bits(ctx, result_type));
>> +       MAYBE_UNUSED const int length = snprintf(name, sizeof(name),
>> "%s.f%d", intrin,
>> +                                                get_elem_bits(ctx,
>> result_type));
>> +       assert(length < sizeof(name));
>>         return ac_build_intrinsic(&ctx->ac, name, result_type, params, 1,
>> AC_FUNC_ATTR_READNONE);
>>   }
>>   @@ -1149,7 +1151,9 @@ static LLVMValueRef emit_intrin_2f_param(struct
>> nir_to_llvm_context *ctx,
>>                 to_float(ctx, src1),
>>         };
>>   -     sprintf(name, "%s.f%d", intrin, get_elem_bits(ctx, result_type));
>> +       MAYBE_UNUSED const int length = snprintf(name, sizeof(name),
>> "%s.f%d", intrin,
>> +                                                get_elem_bits(ctx,
>> result_type));
>> +       assert(length < sizeof(name));
>>         return ac_build_intrinsic(&ctx->ac, name, result_type, params, 2,
>> AC_FUNC_ATTR_READNONE);
>>   }
>>   @@ -1165,7 +1169,9 @@ static LLVMValueRef emit_intrin_3f_param(struct
>> nir_to_llvm_context *ctx,
>>                 to_float(ctx, src2),
>>         };
>>   -     sprintf(name, "%s.f%d", intrin, get_elem_bits(ctx, result_type));
>> +       MAYBE_UNUSED const int length = snprintf(name, sizeof(name),
>> "%s.f%d", intrin,
>> +                                                get_elem_bits(ctx,
>> result_type));
>> +       assert(length < sizeof(name));
>>         return ac_build_intrinsic(&ctx->ac, name, result_type, params, 3,
>> AC_FUNC_ATTR_READNONE);
>>   }
>>   @@ -3425,8 +3431,9 @@ static LLVMValueRef visit_image_atomic(struct
>> nir_to_llvm_context *ctx,
>>         build_int_type_name(LLVMTypeOf(coords),
>>                             coords_type, sizeof(coords_type));
>>   -     snprintf(intrinsic_name, sizeof(intrinsic_name),
>> -                        "%s.%s.%s", base_name, atomic_name, coords_type);
>> +       MAYBE_UNUSED const int length = snprintf(intrinsic_name,
>> sizeof(intrinsic_name),
>> +                                                "%s.%s.%s", base_name,
>> atomic_name, coords_type);
>> +       assert(length < sizeof(intrinsic_name));
>>         return ac_build_intrinsic(&ctx->ac, intrinsic_name, ctx->i32,
>> params, param_count, 0);
>>   }
>>
>
>
>
> --
> Lerne, wie die Welt wirklich ist,
> Aber vergiss niemals, wie sie sein sollte.
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list