19 May, 2011

1 commit


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
     

16 Dec, 2009

2 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
     
  • 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
     

29 Oct, 2009

1 commit

  • strstrip() can return a modified value of its input argument, when
    removing elading whitesapce. So it is surely bug for this function's
    return value to be ignored. The caller is probably going to use the
    incorrect original pointer.

    So mark it __must_check to prevent this frm happening (as it has before).

    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     

06 Apr, 2009

2 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param:
    module: use strstarts()
    strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
    arm: allow usage of string functions in linux/string.h
    module: don't use stop_machine on module load
    module: create a request_module_nowait()
    module: include other structures in module version check
    module: remove the SHF_ALLOC flag on the __versions section.
    module: clarify the force-loading taint message.
    module: Export symbols needed for Ksplice
    Ksplice: Add functions for walking kallsyms symbols
    module: remove module_text_address()
    module: __module_address
    module: Make find_symbol return a struct kernel_symbol
    kernel/module.c: fix an unused goto label
    param: fix charp parameters set via sysfs

    Fix trivial conflicts in kernel/extable.c manually.

    Linus Torvalds
     
  • * 'printk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    printk: correct the behavior of printk_timed_ratelimit()
    vsprintf: unify the format decoding layer for its 3 users, cleanup
    fix regression from "vsprintf: unify the format decoding layer for its 3 users"
    vsprintf: fix bug in negative value printing
    vsprintf: unify the format decoding layer for its 3 users
    vsprintf: add binary printf
    printk: introduce printk_once()

    Fix trivial conflicts (printk_once vs log_buf_kexec_setup() added near
    each other) in include/linux/kernel.h.

    Linus Torvalds
     

01 Apr, 2009

1 commit

  • I notice there are many places doing copy_from_user() which follows
    kmalloc():

    dst = kmalloc(len, GFP_KERNEL);
    if (!dst)
    return -ENOMEM;
    if (copy_from_user(dst, src, len)) {
    kfree(dst);
    return -EFAULT
    }

    memdup_user() is a wrapper of the above code. With this new function, we
    don't have to write 'len' twice, which can lead to typos/mistakes. It
    also produces smaller code and kernel text.

    A quick grep shows 250+ places where memdup_user() *may* be used. I'll
    prepare a patchset to do this conversion.

    Signed-off-by: Li Zefan
    Cc: KOSAKI Motohiro
    Cc: Americo Wang
    Cc: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     

31 Mar, 2009

1 commit


07 Mar, 2009

1 commit

  • Impact: add new APIs for binary trace printk infrastructure

    vbin_printf(): write args to binary buffer, string is copied
    when "%s" is occurred.

    bstr_printf(): read from binary buffer for args and format a string

    [fweisbec@gmail.com: rebase]

    Signed-off-by: Lai Jiangshan
    Signed-off-by: Frederic Weisbecker
    Cc: Linus Torvalds
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Lai Jiangshan
     

03 Nov, 2008

1 commit


25 Jul, 2008

1 commit

  • James Bottomley warns that inclusion of linux/fs.h in a low level
    driver was always a danger signal. This patch moves
    memory_read_from_buffer() from fs.h to string.h and fixes includes in
    existing memory_read_from_buffer() users.

    Signed-off-by: Akinobu Mita
    Cc: James Bottomley
    Cc: Geert Uytterhoeven
    Cc: Zhang Rui
    Cc: Bob Moore
    Cc: Thomas Renninger
    Cc: Len Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

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
     

31 Oct, 2007

1 commit


18 Jul, 2007

2 commits

  • argv_split() is a helper function which takes a string, splits it at
    whitespace, and returns a NULL-terminated argv vector. This is
    deliberately simple - it does no quote processing of any kind.

    [ Seems to me that this is something which is already being done in
    the kernel, but I couldn't find any other implementations, either to
    steal or replace. Keep an eye out. ]

    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Chris Wright
    Cc: Andrew Morton
    Cc: Randy Dunlap

    Jeremy Fitzhardinge
     
  • Add a kstrndup function, modelled on strndup. Like strndup this
    returns a string copied into its own allocated memory, but it copies
    no more than the specified number of bytes from the source.

    Remove private strndup() from irda code.

    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Chris Wright
    Cc: Andrew Morton
    Cc: Randy Dunlap
    Cc: YOSHIFUJI Hideaki
    Cc: Akinobu Mita
    Cc: Arnaldo Carvalho de Melo
    Cc: Al Viro
    Cc: Panagiotis Issaris
    Cc: Rene Scharfe

    Jeremy Fitzhardinge
     

26 Apr, 2007

1 commit


01 Oct, 2006

1 commit

  • One of idiomatic ways to duplicate a region of memory is

    dst = kmalloc(len, GFP_KERNEL);
    if (!dst)
    return -ENOMEM;
    memcpy(dst, src, len);

    which is neat code except a programmer needs to write size twice. Which
    sometimes leads to mistakes. If len passed to kmalloc is smaller that len
    passed to memcpy, it's straight overwrite-beyond-end. If len passed to
    memcpy is smaller than len passed to kmalloc, it's either a) legit
    behaviour ;-), or b) cloned buffer will contain garbage in second half.

    Slight trolling of commit lists shows several duplications bugs
    done exactly because of diverged lenghts:

    Linux:
    [CRYPTO]: Fix memcpy/memset args.
    [PATCH] memcpy/memset fixes
    OpenBSD:
    kerberosV/src/lib/asn1: der_copy.c:1.4

    If programmer is given only one place to play with lengths, I believe, such
    mistakes could be avoided.

    With kmemdup, the snippet above will be rewritten as:

    dst = kmemdup(src, len, GFP_KERNEL);
    if (!dst)
    return -ENOMEM;

    This also leads to smaller code (kzalloc effect). Quick grep shows
    200+ places where kmemdup() can be used.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

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

1 commit

  • 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
     

24 Mar, 2006

1 commit

  • This patch series creates a strndup_user() function to easy copying C strings
    from userspace. Also we avoid common pitfalls like userspace modifying the
    final \0 after the strlen_user().

    Signed-off-by: Davi Arnaut
    Cc: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davi Arnaut
     

09 Oct, 2005

1 commit

  • - added typedef unsigned int __nocast gfp_t;

    - replaced __nocast uses for gfp flags with gfp_t - it gives exactly
    the same warnings as far as sparse is concerned, doesn't change
    generated code (from gcc point of view we replaced unsigned int with
    typedef) and documents what's going on far better.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

08 Jul, 2005

1 commit


24 Jun, 2005

1 commit

  • This patch creates a new kstrdup library function and changes the "local"
    implementations in several places to use this function.

    Most of the changes come from the sound and net subsystems. The sound part
    had already been acknowledged by Takashi Iwai and the net part by David S.
    Miller.

    I left UML alone for now because I would need more time to read the code
    carefully before making changes there.

    Signed-off-by: Paulo Marques
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paulo Marques
     

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