mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] mfd/sm501: Improve a size determination in two functions
Date: Mon, 22 Jan 2018 15:47:33 +0000	[thread overview]
Message-ID: <20180122154733.zpqfqryoyrwo63s2@dell> (raw)
In-Reply-To: <3b264527-b43f-b6aa-0570-c6d48ed24679@users.sourceforge.net>

On Mon, 15 Jan 2018, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 15 Jan 2018 15:47:03 +0100
> 
> Replace the specification of data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/sm501.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> index 7298d6b571a1..d5ab3481794a 100644
> --- a/drivers/mfd/sm501.c
> +++ b/drivers/mfd/sm501.c
> @@ -1380,10 +1380,9 @@ static int sm501_init_dev(struct sm501_devdata *sm)
>  
>  static int sm501_plat_probe(struct platform_device *dev)
>  {
> -	struct sm501_devdata *sm;
>  	int ret;
> +	struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL);
>  
> -	sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);

Leave this here please.

Just s/struct sm501_devdata/*sm/

>  	if (sm == NULL) {
>  		ret = -ENOMEM;
>  		goto err1;
> @@ -1569,10 +1568,9 @@ static struct sm501_platdata sm501_pci_platdata = {
>  static int sm501_pci_probe(struct pci_dev *dev,
>  				     const struct pci_device_id *id)
>  {
> -	struct sm501_devdata *sm;
>  	int err;
> +	struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL);
>  
> -	sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);

As above.

>  	if (sm == NULL) {
>  		err = -ENOMEM;
>  		goto err1;

-- 
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2018-01-22 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 15:12 [PATCH 0/3] mfd/sm501: Adjustments for five function implementations SF Markus Elfring
2018-01-15 15:14 ` [PATCH 1/3] mfd/sm501: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2018-01-22 15:45   ` Lee Jones
2018-01-15 15:15 ` [PATCH 2/3] mfd/sm501: Improve a size determination " SF Markus Elfring
2018-01-22 15:47   ` Lee Jones [this message]
2018-01-15 15:16 ` [PATCH 3/3] mfd/sm501: Adjust 12 checks for null pointers SF Markus Elfring
2018-01-22 15:49   ` Lee Jones
2018-01-23 13:04     ` Lee Jones
2018-01-23 13:34       ` [3/3] " SF Markus Elfring

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=20180122154733.zpqfqryoyrwo63s2@dell \
    --to=lee.jones@linaro.org \
    --cc=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®