lkml.org 
[lkml]   [2015]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 5/8] drivers/base/core.c: Use strreplace
    Date
    This eliminates a little .text and avoids repeating the strchr call
    when we meet a '!' (which will happen at least once).

    Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    ---
    v2: Avoid ugly (char *) cast.

    drivers/base/core.c | 9 ++++-----
    1 file changed, 4 insertions(+), 5 deletions(-)

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 21d13038534e..dafae6d2f7ac 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -1303,12 +1303,11 @@ const char *device_get_devnode(struct device *dev,
    return dev_name(dev);

    /* replace '!' in the name with '/' */
    - *tmp = kstrdup(dev_name(dev), GFP_KERNEL);
    - if (!*tmp)
    + s = kstrdup(dev_name(dev), GFP_KERNEL);
    + if (!s)
    return NULL;
    - while ((s = strchr(*tmp, '!')))
    - s[0] = '/';
    - return *tmp;
    + strreplace(s, '!', '/');
    + return *tmp = s;
    }

    /**
    --
    2.1.3


    \
     
     \ /
      Last update: 2015-06-09 01:41    [W:4.297 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site