Message ID | 238fa39a8fd60e87a5ad7e1ca6584fcdf32e9519.1698159993.git.leonro@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [rdma-next] RDMA/hfi1: Workaround truncation compilation error | expand |
On 10/24/23 11:07 AM, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@nvidia.com> > > 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@nvidia.com> > --- > 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@cornelisnetworks.com>
On Tue, 24 Oct 2023 18:07:31 +0300, Leon Romanovsky wrote: > 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 > > [...] Applied, thanks! [1/1] RDMA/hfi1: Workaround truncation compilation error https://git.kernel.org/rdma/rdma/c/d4b2d165714c0c Best regards,
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 */