public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbou@mail.ru>
To: Akinobu Mita <akinobu.mita@gmail.com>,
	linux-kernel@vger.kernel.org,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] power: use kasprintf
Date: Mon, 26 Nov 2007 02:20:17 +0300	[thread overview]
Message-ID: <20071125232017.GB19266@zarina> (raw)
In-Reply-To: <20071117105558.GA4861@APFDCB5C>

On Sat, Nov 17, 2007 at 07:55:58PM +0900, Akinobu Mita wrote:
> Use kasprintf instead of kmalloc()-strcpy()-strcat().

Applied to battery-2.6.git, thanks.

> Cc: Anton Vorontsov <cbou@mail.ru>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> 
> ---
>  drivers/power/power_supply_leds.c |   25 +++++++------------------
>  1 file changed, 7 insertions(+), 18 deletions(-)
> 
> Index: 2.6-mm/drivers/power/power_supply_leds.c
> ===================================================================
> --- 2.6-mm.orig/drivers/power/power_supply_leds.c
> +++ 2.6-mm/drivers/power/power_supply_leds.c
> @@ -10,6 +10,7 @@
>   *  You may use this code as per GPL version 2
>   */
>  
> +#include <linux/kernel.h>
>  #include <linux/power_supply.h>
>  
>  #include "power_supply.h"
> @@ -48,28 +49,20 @@ static int power_supply_create_bat_trigg
>  {
>  	int rc = 0;
>  
> -	psy->charging_full_trig_name = kmalloc(strlen(psy->name) +
> -				  sizeof("-charging-or-full"), GFP_KERNEL);
> +	psy->charging_full_trig_name = kasprintf(GFP_KERNEL,
> +					"%s-charging-or-full", psy->name);
>  	if (!psy->charging_full_trig_name)
>  		goto charging_full_failed;
>  
> -	psy->charging_trig_name = kmalloc(strlen(psy->name) +
> -					  sizeof("-charging"), GFP_KERNEL);
> +	psy->charging_trig_name = kasprintf(GFP_KERNEL,
> +					"%s-charging", psy->name);
>  	if (!psy->charging_trig_name)
>  		goto charging_failed;
>  
> -	psy->full_trig_name = kmalloc(strlen(psy->name) +
> -				      sizeof("-full"), GFP_KERNEL);
> +	psy->full_trig_name = kasprintf(GFP_KERNEL, "%s-full", psy->name);
>  	if (!psy->full_trig_name)
>  		goto full_failed;
>  
> -	strcpy(psy->charging_full_trig_name, psy->name);
> -	strcat(psy->charging_full_trig_name, "-charging-or-full");
> -	strcpy(psy->charging_trig_name, psy->name);
> -	strcat(psy->charging_trig_name, "-charging");
> -	strcpy(psy->full_trig_name, psy->name);
> -	strcat(psy->full_trig_name, "-full");
> -
>  	led_trigger_register_simple(psy->charging_full_trig_name,
>  				    &psy->charging_full_trig);
>  	led_trigger_register_simple(psy->charging_trig_name,
> @@ -120,14 +113,10 @@ static int power_supply_create_gen_trigg
>  {
>  	int rc = 0;
>  
> -	psy->online_trig_name = kmalloc(strlen(psy->name) + sizeof("-online"),
> -					GFP_KERNEL);
> +	psy->online_trig_name = kasprintf(GFP_KERNEL, "%s-online", psy->name);
>  	if (!psy->online_trig_name)
>  		goto online_failed;
>  
> -	strcpy(psy->online_trig_name, psy->name);
> -	strcat(psy->online_trig_name, "-online");
> -
>  	led_trigger_register_simple(psy->online_trig_name, &psy->online_trig);
>  
>  	goto success;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

      reply	other threads:[~2007-11-25 23:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-17 10:55 [PATCH] power: use kasprintf Akinobu Mita
2007-11-25 23:20 ` Anton Vorontsov [this message]

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=20071125232017.GB19266@zarina \
    --to=cbou@mail.ru \
    --cc=akinobu.mita@gmail.com \
    --cc=dwmw2@infradead.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