lkml.org 
[lkml]   [2018]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/4] bitmap_parselist: don't calculate length of the input string
    Date
    bitmap_parselist() calculates length of the input string before passing
    it to the __bitmap_parselist(). But the end-of-line condition is checked
    for every character in __bitmap_parselist() anyway. So doing it in wrapper
    is a simple waste of time.

    Signed-off-by: Yury Norov <ynorov@marvell.com>
    ---
    lib/bitmap.c | 5 +----
    1 file changed, 1 insertion(+), 4 deletions(-)

    diff --git a/lib/bitmap.c b/lib/bitmap.c
    index eead55aa7170..ad43ba397c58 100644
    --- a/lib/bitmap.c
    +++ b/lib/bitmap.c
    @@ -614,10 +614,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,

    int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
    {
    - char *nl = strchrnul(bp, '\n');
    - int len = nl - bp;
    -
    - return __bitmap_parselist(bp, len, 0, maskp, nmaskbits);
    + return __bitmap_parselist(bp, UINT_MAX, 0, maskp, nmaskbits);
    }
    EXPORT_SYMBOL(bitmap_parselist);

    --
    2.17.1
    \
     
     \ /
      Last update: 2018-12-23 10:47    [W:4.724 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site