Skip to contentSkip to conversation

dmaengine: xilinx: xdma: Workaround truncation compilation error

PATCH In review Vinod Koul 2 participants 2 messages Dec 22, 2023 – Jan 3, 2024

Subsystems (3)
lore
Share & tools
lore

Vinod Koul

author maintainer
#0 lore raw

PATCH 1/1 dmaengine: xilinx: xdma: Workaround truncation compilation error

Increase length to be copied to be large enough to overcome the following compilation error. The buf is large enough for this purpose.

drivers/dma/xilinx/xilinx_dpdma.c: In function ‘xilinx_dpdma_debugfs_desc_done_irq_read’:
drivers/dma/xilinx/xilinx_dpdma.c:313:39: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
313 | snprintf(buf, out_str_len, "%d",
| ^
drivers/dma/xilinx/xilinx_dpdma.c:313:9: note: ‘snprintf’ output between 2 and 6 bytes into a destination of size 5

  313 |         snprintf(buf, out_str_len, "%d",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  314 |                  dpdma_debugfs.xilinx_dpdma_irq_done_count);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 drivers/dma/xilinx/xilinx_dpdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dpdma.c +1 -1
index 69587d85a7cd..b82815e64d24 100644
@@ -309,7 +309,7 @@ static ssize_t xilinx_dpdma_debugfs_desc_done_irq_read(char *buf)
 
 	out_str_len = strlen(XILINX_DPDMA_DEBUGFS_UINT16_MAX_STR);
 	out_str_len = min_t(size_t, XILINX_DPDMA_DEBUGFS_READ_MAX_SIZE,
-			    out_str_len);
+			    out_str_len + 1);
 	snprintf(buf, out_str_len, "%d",
 		 dpdma_debugfs.xilinx_dpdma_irq_done_count);
 
Signature · 1 line
2.43.0
#1 lore raw

Hi Vinod,

This fix should be xilinx_dpdma driver. (dmaengine: xilinx: xilinx_dpdma)

Thanks,

Lizhi

Quoted 31 lines · Vinod Koul

Increase length to be copied to be large enough to overcome the following compilation error. The buf is large enough for this purpose.

drivers/dma/xilinx/xilinx_dpdma.c: In function ‘xilinx_dpdma_debugfs_desc_done_irq_read’:
drivers/dma/xilinx/xilinx_dpdma.c:313:39: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
313 | snprintf(buf, out_str_len, "%d",
| ^
drivers/dma/xilinx/xilinx_dpdma.c:313:9: note: ‘snprintf’ output between 2 and 6 bytes into a destination of size 5

   313 |         snprintf(buf, out_str_len, "%d",
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   314 |                  dpdma_debugfs.xilinx_dpdma_irq_done_count);
       |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
  drivers/dma/xilinx/xilinx_dpdma.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dpdma.c +1 -1
index 69587d85a7cd..b82815e64d24 100644
@@ -309,7 +309,7 @@ static ssize_t xilinx_dpdma_debugfs_desc_done_irq_read(char *buf)
 
  	out_str_len = strlen(XILINX_DPDMA_DEBUGFS_UINT16_MAX_STR);
  	out_str_len = min_t(size_t, XILINX_DPDMA_DEBUGFS_READ_MAX_SIZE,
-			    out_str_len);
+			    out_str_len + 1);
  	snprintf(buf, out_str_len, "%d",
  		 dpdma_debugfs.xilinx_dpdma_irq_done_count);