All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: be2iscsi: Use kasprintf
@ 2017-10-06 18:57 Himanshu Jha
  2017-10-10 21:54 ` Kyle Fortin
  0 siblings, 1 reply; 3+ messages in thread
From: Himanshu Jha @ 2017-10-06 18:57 UTC (permalink / raw)
  To: jejb
  Cc: martin.petersen, subbu.seetharaman, ketan.mukadam,
	jitendra.bhivare, linux-scsi, linux-kernel, Himanshu Jha

Use kasprintf instead of combination of kmalloc and sprintf.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
 drivers/scsi/be2iscsi/be_main.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b4542e7..6a9ee0e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 
 	if (pcidev->msix_enabled) {
 		for (i = 0; i < phba->num_cpus; i++) {
-			phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
-						    GFP_KERNEL);
+			phba->msi_name[i] = kasprintf(GFP_KERNEL,
+						      "beiscsi_%02x_%02x",
+						      phba->shost->host_no, i);
 			if (!phba->msi_name[i]) {
 				ret = -ENOMEM;
 				goto free_msix_irqs;
 			}
 
-			sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
-				phba->shost->host_no, i);
 			ret = request_irq(pci_irq_vector(pcidev, i),
 					  be_isr_msix, 0, phba->msi_name[i],
 					  &phwi_context->be_eq[i]);
@@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 				goto free_msix_irqs;
 			}
 		}
-		phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
+		phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
+					      phba->shost->host_no);
 		if (!phba->msi_name[i]) {
 			ret = -ENOMEM;
 			goto free_msix_irqs;
 		}
-		sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
-			phba->shost->host_no);
 		ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
 				  phba->msi_name[i], &phwi_context->be_eq[i]);
 		if (ret) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: be2iscsi: Use kasprintf
  2017-10-06 18:57 [PATCH] scsi: be2iscsi: Use kasprintf Himanshu Jha
@ 2017-10-10 21:54 ` Kyle Fortin
  2017-10-11  6:54   ` Himanshu Jha
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Fortin @ 2017-10-10 21:54 UTC (permalink / raw)
  To: Himanshu Jha
  Cc: jejb, martin.petersen, subbu.seetharaman, ketan.mukadam,
	jitendra.bhivare, linux-scsi, linux-kernel

Hi Himanshu,

On Oct 6, 2017, at 2:57 PM, Himanshu Jha <himanshujha199640@gmail.com> wrote:
> 
> Use kasprintf instead of combination of kmalloc and sprintf.
> 
> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
> ---
> drivers/scsi/be2iscsi/be_main.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index b4542e7..6a9ee0e 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> 
> 	if (pcidev->msix_enabled) {
> 		for (i = 0; i < phba->num_cpus; i++) {
> -			phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> -						    GFP_KERNEL);
> +			phba->msi_name[i] = kasprintf(GFP_KERNEL,
> +						      "beiscsi_%02x_%02x",
> +						      phba->shost->host_no, i);
> 			if (!phba->msi_name[i]) {
> 				ret = -ENOMEM;
> 				goto free_msix_irqs;
> 			}
> 
> -			sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> -				phba->shost->host_no, i);
> 			ret = request_irq(pci_irq_vector(pcidev, i),
> 					  be_isr_msix, 0, phba->msi_name[i],
> 					  &phwi_context->be_eq[i]);
> @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> 				goto free_msix_irqs;
> 			}
> 		}
> -		phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> +		phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> +					      phba->shost->host_no);
> 		if (!phba->msi_name[i]) {
> 			ret = -ENOMEM;
> 			goto free_msix_irqs;
> 		}
> -		sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> -			phba->shost->host_no);
> 		ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
> 				  phba->msi_name[i], &phwi_context->be_eq[i]);
> 		if (ret) {
> -- 
> 2.7.4

Since you are getting rid of the only use for BEISCSI_MSI_NAME within drivers/scsi/be2iscsi/be_main.h, that should be removed too.

--
Kyle Fortin - Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: be2iscsi: Use kasprintf
  2017-10-10 21:54 ` Kyle Fortin
@ 2017-10-11  6:54   ` Himanshu Jha
  0 siblings, 0 replies; 3+ messages in thread
From: Himanshu Jha @ 2017-10-11  6:54 UTC (permalink / raw)
  To: Kyle Fortin
  Cc: jejb, martin.petersen, subbu.seetharaman, ketan.mukadam,
	jitendra.bhivare, linux-scsi, linux-kernel

On Tue, Oct 10, 2017 at 05:54:15PM -0400, Kyle Fortin wrote:
> Hi Himanshu,
> 
> On Oct 6, 2017, at 2:57 PM, Himanshu Jha <himanshujha199640@gmail.com> wrote:
> > 
> > Use kasprintf instead of combination of kmalloc and sprintf.
> > 
> > Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
> > ---
> > drivers/scsi/be2iscsi/be_main.c | 12 +++++-------
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> > index b4542e7..6a9ee0e 100644
> > --- a/drivers/scsi/be2iscsi/be_main.c
> > +++ b/drivers/scsi/be2iscsi/be_main.c
> > @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> > 
> > 	if (pcidev->msix_enabled) {
> > 		for (i = 0; i < phba->num_cpus; i++) {
> > -			phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> > -						    GFP_KERNEL);
> > +			phba->msi_name[i] = kasprintf(GFP_KERNEL,
> > +						      "beiscsi_%02x_%02x",
> > +						      phba->shost->host_no, i);
> > 			if (!phba->msi_name[i]) {
> > 				ret = -ENOMEM;
> > 				goto free_msix_irqs;
> > 			}
> > 
> > -			sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> > -				phba->shost->host_no, i);
> > 			ret = request_irq(pci_irq_vector(pcidev, i),
> > 					  be_isr_msix, 0, phba->msi_name[i],
> > 					  &phwi_context->be_eq[i]);
> > @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> > 				goto free_msix_irqs;
> > 			}
> > 		}
> > -		phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> > +		phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> > +					      phba->shost->host_no);
> > 		if (!phba->msi_name[i]) {
> > 			ret = -ENOMEM;
> > 			goto free_msix_irqs;
> > 		}
> > -		sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> > -			phba->shost->host_no);
> > 		ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
> > 				  phba->msi_name[i], &phwi_context->be_eq[i]);
> > 		if (ret) {
> > -- 
> > 2.7.4
> 
> Since you are getting rid of the only use for BEISCSI_MSI_NAME within drivers/scsi/be2iscsi/be_main.h, that should be removed too.

Yes, that should be removed! Thanks for pointing that out.
I will send a v2 patch with the update.

> --
> Kyle Fortin - Oracle Linux Engineering
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-11  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-06 18:57 [PATCH] scsi: be2iscsi: Use kasprintf Himanshu Jha
2017-10-10 21:54 ` Kyle Fortin
2017-10-11  6:54   ` Himanshu Jha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.