diff mbox series

[rdma-next,1/2] RDMA/qib: Fix truncation compilation warnings in qib_init.c

Message ID ab5222c414a01e9d2c5129ef26836aace9ee2aa5.1719837715.git.leon@kernel.org (mailing list archive)
State Accepted
Headers show
Series [rdma-next,1/2] RDMA/qib: Fix truncation compilation warnings in qib_init.c | expand

Commit Message

Leon Romanovsky July 1, 2024, 12:42 p.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

drivers/infiniband/hw/qib/qib_init.c: In function ‘qib_init_one’:
drivers/infiniband/hw/qib/qib_init.c:586:67: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 3 [-Werror=format-truncation=]
  586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
      |                                                                   ^~
In function ‘qib_create_workqueues’,
    inlined from ‘qib_init_one’ at drivers/infiniband/hw/qib/qib_init.c:1438:8:
drivers/infiniband/hw/qib/qib_init.c:586:60: note: directive argument in the range [-2147483643, 254]
  586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
      |                                                            ^~~~~~~~~~
drivers/infiniband/hw/qib/qib_init.c:586:25: note: ‘snprintf’ output between 7 and 27 bytes into a destination of size 8
  586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  587 |                                 dd->unit, pidx);
      |                                 ~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/qib/qib_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dennis Dalessandro July 2, 2024, 6:04 p.m. UTC | #1
On 7/1/24 8:42 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> drivers/infiniband/hw/qib/qib_init.c: In function ‘qib_init_one’:
> drivers/infiniband/hw/qib/qib_init.c:586:67: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 3 [-Werror=format-truncation=]
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                                                                   ^~
> In function ‘qib_create_workqueues’,
>     inlined from ‘qib_init_one’ at drivers/infiniband/hw/qib/qib_init.c:1438:8:
> drivers/infiniband/hw/qib/qib_init.c:586:60: note: directive argument in the range [-2147483643, 254]
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                                                            ^~~~~~~~~~
> drivers/infiniband/hw/qib/qib_init.c:586:25: note: ‘snprintf’ output between 7 and 27 bytes into a destination of size 8
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   587 |                                 dd->unit, pidx);
>       |                                 ~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/hw/qib/qib_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
> index 33667becd52b..db3b25c8433a 100644
> --- a/drivers/infiniband/hw/qib/qib_init.c
> +++ b/drivers/infiniband/hw/qib/qib_init.c
> @@ -581,7 +581,7 @@ static int qib_create_workqueues(struct qib_devdata *dd)
>  	for (pidx = 0; pidx < dd->num_pports; ++pidx) {
>  		ppd = dd->pport + pidx;
>  		if (!ppd->qib_wq) {
> -			char wq_name[8]; /* 3 + 2 + 1 + 1 + 1 */
> +			char wq_name[23];
>  
>  			snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>  				dd->unit, pidx);

Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Leon Romanovsky July 4, 2024, 4:57 a.m. UTC | #2
On Mon, 01 Jul 2024 15:42:28 +0300, Leon Romanovsky wrote:
> drivers/infiniband/hw/qib/qib_init.c: In function ‘qib_init_one’:
> drivers/infiniband/hw/qib/qib_init.c:586:67: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 3 [-Werror=format-truncation=]
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                                                                   ^~
> In function ‘qib_create_workqueues’,
>     inlined from ‘qib_init_one’ at drivers/infiniband/hw/qib/qib_init.c:1438:8:
> drivers/infiniband/hw/qib/qib_init.c:586:60: note: directive argument in the range [-2147483643, 254]
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                                                            ^~~~~~~~~~
> drivers/infiniband/hw/qib/qib_init.c:586:25: note: ‘snprintf’ output between 7 and 27 bytes into a destination of size 8
>   586 |                         snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   587 |                                 dd->unit, pidx);
>       |                                 ~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> [...]

Applied, thanks!

[1/2] RDMA/qib: Fix truncation compilation warnings in qib_init.c
      https://git.kernel.org/rdma/rdma/c/1b8ca05469315e
[2/2] RDMA/qib: Fix truncation compilation warnings in qib_verbs.c
      https://git.kernel.org/rdma/rdma/c/f802078d3cb882

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index 33667becd52b..db3b25c8433a 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -581,7 +581,7 @@  static int qib_create_workqueues(struct qib_devdata *dd)
 	for (pidx = 0; pidx < dd->num_pports; ++pidx) {
 		ppd = dd->pport + pidx;
 		if (!ppd->qib_wq) {
-			char wq_name[8]; /* 3 + 2 + 1 + 1 + 1 */
+			char wq_name[23];
 
 			snprintf(wq_name, sizeof(wq_name), "qib%d_%d",
 				dd->unit, pidx);