From 48b093ba65146dc5bdfe6fffafde26e30b44f8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Sat, 18 Mar 2023 15:45:43 +0200 Subject: sna/gen3: Silence compiler warn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../src/sna/kgem_debug_gen3.c:1289:50: warning: ‘%03d’ directive writing between 3 and 10 bytes into a region of size 8 [-Wformat-overflow=] 1289 | sprintf(instr_prefix, "PS%03d", instr); | ^~~~ ../src/sna/kgem_debug_gen3.c:1289:47: note: directive argument in the range [0, 1431655764] 1289 | sprintf(instr_prefix, "PS%03d", instr); | ^~~~~~~~ ../src/sna/kgem_debug_gen3.c:1289:25: note: ‘sprintf’ output between 6 and 13 bytes into a destination of size 10 1289 | sprintf(instr_prefix, "PS%03d", instr); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The compiler is utterly wrong here of course since 'instr' will at most be (0x1ff + 2 - 1) / 3 ~= 170 (though the hardware defined max is actually only 123). But let's bump the buffer size a little bit to shut the compiler up. Signed-off-by: Ville Syrjälä --- src/sna/kgem_debug_gen3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sna/kgem_debug_gen3.c b/src/sna/kgem_debug_gen3.c index 4a7b1aaa..a52ee61d 100644 --- a/src/sna/kgem_debug_gen3.c +++ b/src/sna/kgem_debug_gen3.c @@ -1284,7 +1284,7 @@ gen3_decode_3d_1d(struct kgem *kgem, uint32_t offset) assert(len <= 370); i = 1; for (instr = 0; instr < (len - 1) / 3; instr++) { - char instr_prefix[10]; + char instr_prefix[13]; sprintf(instr_prefix, "PS%03d", instr); gen3_decode_instruction(data, offset, i, instr_prefix); -- cgit v1.2.3