All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: SF Markus Elfring <elfring@users.sourceforge.net>,
	sparclinux@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions
Date: Mon, 29 Aug 2016 13:57:41 +0200	[thread overview]
Message-ID: <57C42335.5000106@bfs.de> (raw)
In-Reply-To: <4475e65d-415d-9cde-1fe1-c17e120849c4@redhat.com>



Am 29.08.2016 11:47, schrieb Paolo Bonzini:
> 
> 
> On 25/08/2016 10:22, SF Markus Elfring wrote:
>> --- a/arch/sparc/kernel/led.c
>> +++ b/arch/sparc/kernel/led.c
>> @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer,
>>  	if (count > LED_MAX_LENGTH)
>>  		count = LED_MAX_LENGTH;
>>  
>> -	buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
>> +	buf = kmalloc_array(count + 1, sizeof(*buf), GFP_KERNEL);
>>  	if (!buf)
>>  		return -ENOMEM;
>>  
> 
> Here it's probably best to just remove sizeof(char) completely, as it's
> 1 by definition.
> 
> Paolo


I would not do so, if you ever change buf to something else it would break,
having a sizeof(*buf) here is harmless and a known pattern.

re,
 wh

WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: SF Markus Elfring <elfring@users.sourceforge.net>,
	sparclinux@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions
Date: Mon, 29 Aug 2016 11:57:41 +0000	[thread overview]
Message-ID: <57C42335.5000106@bfs.de> (raw)
In-Reply-To: <4475e65d-415d-9cde-1fe1-c17e120849c4@redhat.com>



Am 29.08.2016 11:47, schrieb Paolo Bonzini:
> 
> 
> On 25/08/2016 10:22, SF Markus Elfring wrote:
>> --- a/arch/sparc/kernel/led.c
>> +++ b/arch/sparc/kernel/led.c
>> @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer,
>>  	if (count > LED_MAX_LENGTH)
>>  		count = LED_MAX_LENGTH;
>>  
>> -	buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
>> +	buf = kmalloc_array(count + 1, sizeof(*buf), GFP_KERNEL);
>>  	if (!buf)
>>  		return -ENOMEM;
>>  
> 
> Here it's probably best to just remove sizeof(char) completely, as it's
> 1 by definition.
> 
> Paolo


I would not do so, if you ever change buf to something else it would break,
having a sizeof(*buf) here is harmless and a known pattern.

re,
 wh

  parent reply	other threads:[~2016-08-29 11:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25  8:20 [PATCH 0/2] sparc: Fine-tuning for three function implementations SF Markus Elfring
2016-08-25  8:20 ` SF Markus Elfring
2016-08-25  8:22 ` [PATCH 1/2] sparc: Use kmalloc_array() in three functions SF Markus Elfring
2016-08-25  8:22   ` SF Markus Elfring
2016-08-29  9:47   ` Paolo Bonzini
2016-08-29  9:47     ` Paolo Bonzini
2016-08-29 10:36     ` SF Markus Elfring
2016-08-29 10:36       ` SF Markus Elfring
2016-08-29 11:57     ` walter harms [this message]
2016-08-29 11:57       ` walter harms
2016-08-29 16:38       ` Paolo Bonzini
2016-08-29 16:38         ` Paolo Bonzini
2016-08-25  8:24 ` [PATCH 2/2] sparc: Delete an unnecessary initialisation in led_proc_write() SF Markus Elfring
2016-08-25  8:24   ` 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=57C42335.5000106@bfs.de \
    --to=wharms@bfs.de \
    --cc=davem@davemloft.net \
    --cc=elfring@users.sourceforge.net \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sparclinux@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 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.