Re: [PATCH rdma-next] RDMA/hfi1: Workaround truncation compilation error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/24/23 11:07 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxx>
> 
> Increase name array to be large enough to overcome the following
> compilation error.
> 
> drivers/infiniband/hw/hfi1/efivar.c: In function ‘read_hfi1_efi_var’:
> drivers/infiniband/hw/hfi1/efivar.c:124:44: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
>   124 |         snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
>       |                                            ^
> drivers/infiniband/hw/hfi1/efivar.c:124:9: note: ‘snprintf’ output 2 or more bytes (assuming 65) into a destination of size 64
>   124 |         snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/infiniband/hw/hfi1/efivar.c:133:52: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
>   133 |                 snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
>       |                                                    ^
> drivers/infiniband/hw/hfi1/efivar.c:133:17: note: ‘snprintf’ output 2 or more bytes (assuming 65) into a destination of size 64
>   133 |                 snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[6]: *** [scripts/Makefile.build:243: drivers/infiniband/hw/hfi1/efivar.o] Error 1
> 
> Fixes: c03c08d50b3d ("IB/hfi1: Check upper-case EFI variables")
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
> ---
>  drivers/infiniband/hw/hfi1/efivar.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/efivar.c b/drivers/infiniband/hw/hfi1/efivar.c
> index fb06e86da608..9ed05e10020e 100644
> --- a/drivers/infiniband/hw/hfi1/efivar.c
> +++ b/drivers/infiniband/hw/hfi1/efivar.c
> @@ -112,7 +112,7 @@ int read_hfi1_efi_var(struct hfi1_devdata *dd, const char *kind,
>  		      unsigned long *size, void **return_data)
>  {
>  	char prefix_name[64];
> -	char name[64];
> +	char name[128];
>  	int result;
>  
>  	/* create a common prefix */

Thanks for the patch.

Acked-by: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxxxxxxxxxxxxx>



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux