[PATCH 2/2] media: atomisp: Fix Wformat-truncation warning

Ricardo Ribalda posted 2 patches 10 months, 2 weeks ago
There is a newer version of this series
[PATCH 2/2] media: atomisp: Fix Wformat-truncation warning
Posted by Ricardo Ribalda 10 months, 2 weeks ago
Gcc8 is convinced that we do not have enough space in dot_id_input_bin.
Extend the variable 17 bytes. It is just used for debugging.

drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c:1336:9: warning: '(pipe' directive output may be truncated writing 5 bytes into a region of size between 1 and 74 [-Wformat-truncation=]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c
index 9818771a35e550c0ce98da826caff5f834867e7c..45af23f09c0ae67a2dd62e79457b548831b8c21e 100644
--- a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c
+++ b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c
@@ -121,7 +121,7 @@ static const char *const pipe_id_to_str[] = {
 	/* [IA_CSS_PIPE_ID_YUVPP]     =*/ "yuvpp",
 };
 
-static char dot_id_input_bin[SH_CSS_MAX_BINARY_NAME + 10];
+static char dot_id_input_bin[SH_CSS_MAX_BINARY_NAME + 27];
 static char ring_buffer[200];
 
 void ia_css_debug_dtrace(unsigned int level, const char *fmt, ...)

-- 
2.49.0.472.ge94155a9ec-goog
Re: [PATCH 2/2] media: atomisp: Fix Wformat-truncation warning
Posted by Andy Shevchenko 10 months, 1 week ago
On Mon, Mar 31, 2025 at 7:38 PM Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Gcc8 is convinced that we do not have enough space in dot_id_input_bin.
> Extend the variable 17 bytes. It is just used for debugging.
>
> drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c:1336:9: warning: '(pipe' directive output may be truncated writing 5 bytes into a region of size between 1 and 74 [-Wformat-truncation=]

...

> -static char dot_id_input_bin[SH_CSS_MAX_BINARY_NAME + 10];
> +static char dot_id_input_bin[SH_CSS_MAX_BINARY_NAME + 27];

I'm okay with the approach, but can you also add a comment to explain
27, please?
(I mean something like "27 is the combined length of 'pipe' plus ...")

-- 
With Best Regards,
Andy Shevchenko