Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4d24473c435c7c3ad7b43e43b70cdb16aba25443
Commit:     4d24473c435c7c3ad7b43e43b70cdb16aba25443
Parent:     25f12141e2be96e904239d963e25818b8854e72f
Author:     Akinobu Mita <[EMAIL PROTECTED]>
AuthorDate: Sat Nov 17 19:55:58 2007 +0900
Committer:  Anton Vorontsov <[EMAIL PROTECTED]>
CommitDate: Sat Feb 2 02:42:59 2008 +0300

    [BATTERY] power_supply_leds: use kasprintf
    
    Use kasprintf instead of kmalloc()-strcpy()-strcat().
    
    Cc: Anton Vorontsov <[EMAIL PROTECTED]>
    Cc: David Woodhouse <[EMAIL PROTECTED]>
    Signed-off-by: Akinobu Mita <[EMAIL PROTECTED]>
    Signed-off-by: Anton Vorontsov <[EMAIL PROTECTED]>
---
 drivers/power/power_supply_leds.c |   25 +++++++------------------
 1 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/power/power_supply_leds.c 
b/drivers/power/power_supply_leds.c
index 80ca288..fa3034f 100644
--- a/drivers/power/power_supply_leds.c
+++ b/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_triggers(struct 
power_supply *psy)
 {
        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_triggers(struct 
power_supply *psy)
 {
        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 git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to