linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <openosd@gmail.com>
To: Matei Oprea <eu@opreamatei.ro>, jbottomley@parallels.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	ROSEdu Kernel Community <firefly@lists.rosedu.org>
Subject: Re: [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
Date: Wed, 09 Apr 2014 13:48:29 +0300	[thread overview]
Message-ID: <5345257D.6040102@gmail.com> (raw)
In-Reply-To: <1396989746-29647-1-git-send-email-eu@opreamatei.ro>

On 04/08/2014 11:42 PM, Matei Oprea wrote:
> It's easier to use kcalloc for allocating arrays. While at it
> also remove useless casting value.
> 
> Signed-off-by: Matei Oprea <eu@opreamatei.ro>
> Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
> ---
>  drivers/scsi/lpfc/lpfc_init.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index 635eeb3..1528f34 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -4742,12 +4742,14 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
>  			phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT;
>  	}
>  
> -	if (!phba->sli.ring)
> -		phba->sli.ring = (struct lpfc_sli_ring *)
> -			kzalloc(LPFC_SLI3_MAX_RING *
> -			sizeof(struct lpfc_sli_ring), GFP_KERNEL);
> -	if (!phba->sli.ring)
> -		return -ENOMEM;
> +	if (unlikely(!phba->sli.ring)) {

As Joe Perches said this one is not unlikely, it might or it might not
depending on state.

> +		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
> +				sizeof(struct lpfc_sli_ring),
> +				GFP_KERNEL);
> +
> +		if (!phba->sli.ring)

but this one is unlikely. This is the error path so we want
the hot path to be decoded by the CPU.

> +			return -ENOMEM;
> +	}
>  
>  	/*
>  	 * Since lpfc_sg_seg_cnt is module parameter, the sg_dma_buf_size
> 

Cheers
Boaz

  parent reply	other threads:[~2014-04-09 10:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08 20:42 [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory Matei Oprea
2014-04-09  0:04 ` Joe Perches
2014-04-09 10:48 ` Boaz Harrosh [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-04-11  9:21 Matei Oprea
2014-04-08 20:18 Matei Oprea
2014-04-08 20:20 ` Joe Perches
2014-04-08 20:21   ` Matei Oprea
2014-04-08 19:44 Matei Oprea
2014-04-08 19:48 ` Joe Perches
2014-03-18 20:51 Matei Oprea
2014-04-07 12:37 ` Matei Oprea
2014-04-08  6:36 ` Boaz Harrosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5345257D.6040102@gmail.com \
    --to=openosd@gmail.com \
    --cc=eu@opreamatei.ro \
    --cc=firefly@lists.rosedu.org \
    --cc=jbottomley@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).