01 Nov, 2011

2 commits

  • Commit 84c95c9acf0 ("string: on strstrip(), first remove leading spaces
    before running over str") improved the performance of the strim()
    function.

    Unfortunately this changed the semantics of strim() and broke my code.
    Before the patch it was possible to use strim() without using the return
    value for removing trailing spaces from strings that had either only
    blanks or only trailing blanks.

    Now this does not work any longer for strings that *only* have blanks.

    Before patch: " " -> "" (empty string)
    After patch: " " -> " " (no change)

    I think we should remove your patch to restore the old behavior.

    The description (lib/string.c):

    * Note that the first trailing whitespace is replaced with a %NUL-terminator

    => The first trailing whitespace of a string that only has whitespace
    characters is the first whitespace

    The patch restores the old strim() semantics.

    Signed-off-by: Michael Holzheu
    Cc: Andre Goddard Rosa
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Holzheu
     
  • memchr_inv() is mainly used to check whether the whole buffer is filled
    with just a specified byte.

    The function name and prototype are stolen from logfs and the
    implementation is from SLUB.

    Signed-off-by: Akinobu Mita
    Acked-by: Christoph Lameter
    Acked-by: Pekka Enberg
    Cc: Matt Mackall
    Acked-by: Joern Engel
    Cc: Marcin Slusarz
    Cc: Eric Dumazet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

19 May, 2011

1 commit


07 Mar, 2010

2 commits


15 Jan, 2010

1 commit

  • It differs strstr() in that it limits the length to be searched
    in the first string.

    Signed-off-by: Li Zefan
    LKML-Reference:
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Li Zefan
     

23 Dec, 2009

1 commit

  • Fix kernel-doc warnings (@arg name) in string.c::skip_spaces().

    Warning(lib/string.c:347): No description found for parameter 'str'
    Warning(lib/string.c:347): Excess function parameter 's' description in 'skip_spaces'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

16 Dec, 2009

3 commits

  • Recently, We marked strstrip() as must_check. because it was frequently
    misused and it should be checked. However, we found one exception.
    scsi/ipr.c intentionally ignore return value of strstrip. Because it
    wishes to keep the whitespace at the beginning.

    Thus we need to keep with and without checked whitespace trim function.
    This patch adds a new strim() and changes ipr.c to use it.

    [akpm@linux-foundation.org: coding-style fixes]
    Suggested-by: Alan Cox
    Signed-off-by: KOSAKI Motohiro
    Cc: James Bottomley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • ... so that strlen() iterates over a smaller string comprising of the
    remaining characters only.

    Signed-off-by: André Goddard Rosa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    André Goddard Rosa
     
  • On the following sentence:
    while (*s && isspace(*s))
    s++;

    If *s == 0, isspace() evaluates to ((_ctype[*s] & 0x20) != 0), which
    evaluates to ((0x08 & 0x20) != 0) which equals to 0 as well.
    If *s == 1, we depend on isspace() result anyway. In other words,
    "a char equals zero is never a space", so remove this check.

    Also, *s != 0 is most common case (non-null string).

    Fixed const return as noticed by Jan Engelhardt and James Bottomley.
    Fixed unnecessary extra cast on strstrip() as noticed by Jan Engelhardt.

    Signed-off-by: André Goddard Rosa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    André Goddard Rosa
     

19 Nov, 2009

1 commit

  • Doing the strcmp return value as

    signed char __res = *cs - *ct;

    is wrong for two reasons. The subtraction can overflow because __res
    doesn't use a type big enough. Moreover the compared bytes should be
    interpreted as unsigned char as specified by POSIX.

    The same problem is fixed in strncmp.

    Signed-off-by: Uwe Kleine-König
    Cc: Michael Buesch
    Cc: Andreas Schwab
    Cc: Andrew Morton
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

01 May, 2008

1 commit

  • Add a new sysfs_streq() string comparison function, which ignores
    the trailing newlines found in sysfs inputs. By example:

    sysfs_streq("a", "b") ==> false
    sysfs_streq("a", "a") ==> true
    sysfs_streq("a", "a\n") ==> true
    sysfs_streq("a\n", "a") ==> true

    This is intended to simplify parsing of sysfs inputs, letting them
    avoid the need to manually strip off newlines from inputs.

    Signed-off-by: David Brownell
    Acked-by: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

26 Apr, 2007

1 commit


12 Feb, 2007

1 commit

  • A variety of (mostly) innocuous fixes to the embedded kernel-doc content in
    source files, including:

    * make multi-line initial descriptions single line
    * denote some function names, constants and structs as such
    * change erroneous opening '/*' to '/**' in a few places
    * reword some text for clarity

    Signed-off-by: Robert P. J. Day
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

29 Oct, 2006

1 commit

  • strstrip() does not remove the last blank from strings which only consist
    of blanks.

    Example:
    char string[] = " ";
    strstrip(string);

    results in " ", but should produce an empty string!

    The following patch solves this problem:

    Acked-by: Martin Schwidefsky
    Signed-off-by: Michael Holzheu
    Acked-by: Pekka Enberg
    Acked-by Joern Engel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Holzheu
     

23 Jun, 2006

1 commit

  • Add a new strstrip() function to lib/string.c for removing leading and
    trailing whitespace from a string.

    Cc: Michael Holzheu
    Acked-by: Ingo Oeser
    Acked-by: Joern Engel
    Cc: Corey Minyard
    Signed-off-by: Pekka Enberg
    Acked-by: Michael Holzheu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     

11 Apr, 2006

3 commits

  • lib/string.c: In function 'memcpy':
    lib/string.c:470: warning: initialization discards qualifiers from pointer =
    target type

    Signed-off-by: Jan-Benedict Glaw
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan-Benedict Glaw
     
  • Some string functions were safely overrideable in lib/string.c, but their
    corresponding declarations in linux/string.h were not. Correct this, and
    make strcspn overrideable.

    Odds of someone wanting to do optimized assembly of these are small, but
    for the sake of cleanliness, might as well bring them into line with the
    rest of the file.

    Signed-off-by: Kyle McMartin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kyle McMartin
     
  • While cleaning up parisc_ksyms.c earlier, I noticed that strpbrk wasn't
    being exported from lib/string.c. Investigating further, I noticed a
    changeset that removed its export and added it to _ksyms.c on a few more
    architectures. The justification was that "other arches do it."

    I think this is wrong, since no architecture currently defines
    __HAVE_ARCH_STRPBRK, there's no reason for any of them to be exporting it
    themselves. Therefore, consolidate the export to lib/string.c.

    Signed-off-by: Kyle McMartin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kyle McMartin
     

22 Mar, 2006

1 commit

  • Sam's tree includes a new check, which found that we're exporting strpbrk()
    multiple times.

    It seems that the convention is that this is exported from the arch files, so
    reove the lib/string.c export.

    Cc: Sam Ravnborg
    Cc: Yoshinori Sato
    Cc: David Howells
    Cc: Greg Ungerer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

31 Oct, 2005

4 commits

  • A couple of (char *) casts removed in a previous cleanup patch in
    lib/string.c:memmove() were actually useful, as they suppressed a couple of
    warnings:

    assignment discards qualifiers from pointer target type

    Fix by declaring the local variable const in the first place, so casts
    aren't needed to strip the const qualifier.

    Signed-off-by: Paul Jackson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     
  • The first two hunks of the patch really belongs in patch 1, but I missed
    them on the first pass and instead of redoing all 3 patches I stuck them in
    this one.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • Removes a few pointless register keywords. register is merely a compiler
    hint that access to the variable should be optimized, but gcc (3.3.6 in my
    case) generates the exact same code with and without the keyword, and even
    if gcc did something different with register present I think it is doubtful
    we would want to optimize access to these variables - especially since this
    is generic library code and there are supposed to be optimized versions in
    asm/ for anything that really matters speed wise.

    (akpm: iirc, keyword register is a gcc no-op unless using -O0)

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • Removes some blank lines, removes some trailing whitespace, adds spaces
    after commas and a few similar changes.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     

06 May, 2005

2 commits

  • this clarifies the documentation on the behavier of strncpy().

    Signed-off-by: Domen Puncer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    walter harms
     
  • In include/asm-x86_64/string.h there are such comments:

    /* Use C out of line version for memcmp */
    #define memcmp __builtin_memcmp
    int memcmp(const void * cs,const void * ct,size_t count);

    This would mean that if the compiler does not decide to use __builtin_memcmp,
    it emits a call to memcmp to be satisfied by the C out-of-line version in
    lib/string.c. What happens is that after preprocessing, in lib/string.i you
    may find the definition of "__builtin_strcmp".

    Actually, by accident, in the object you will find the definition of strcmp
    and such (maybe a trick intended to redirect calls to __builtin_memcmp to the
    default memcmp when the definition is not expanded); however, this particular
    case is not a documented feature as far as I can see.

    Also, the EXPORT_SYMBOL does not work, so it's duplicated in the arch.

    I simply added some #undef to lib/string.c and removed the (now duplicated)
    exports in x86-64 and UML/x86_64 subarchs (the second ones are introduced by
    another patch I just posted for -mm).

    Signed-off-by: Paolo 'Blaisorblade' Giarrusso
    CC: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paolo 'Blaisorblade' Giarrusso
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds