summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Legg <[email protected]>2017-06-23 11:18:57 +0100
committerBas Nieuwenhuizen <[email protected]>2017-06-28 21:05:04 +0200
commit69a17da037d26b54e075d90c8b5ce887255291a7 (patch)
tree30405b8e29ad663c0cbf04bf597e0d29e88f3be0
parent6fc41bb4d59313985f67b1276d1fd1225be09426 (diff)
ac/nir: assert printfs will fit
Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r--src/amd/common/ac_nir_to_llvm.c17
1 files 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 b5c6848bf59..a02968efc86 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1133,7 +1133,9 @@ static LLVMValueRef emit_intrin_1f_param(struct ac_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, name, result_type, params, 1, AC_FUNC_ATTR_READNONE);
}
@@ -1148,7 +1150,9 @@ static LLVMValueRef emit_intrin_2f_param(struct ac_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, name, result_type, params, 2, AC_FUNC_ATTR_READNONE);
}
@@ -1164,7 +1168,9 @@ static LLVMValueRef emit_intrin_3f_param(struct ac_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, name, result_type, params, 3, AC_FUNC_ATTR_READNONE);
}
@@ -3456,8 +3462,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);
}