aboutsummaryrefslogtreecommitdiff
path: root/include/linux/string.h
AgeCommit message (Collapse)AuthorFilesLines
2009-03-31strstarts: helper function for !strncmp(str, prefix, strlen(prefix))Rusty Russell1-0/+9
Impact: minor new API ksplice added a "starts_with" function, which seems like a common need. When people open-code it they seem to use fixed numbers rather than strlen, so it's quite a readability win (also, strncmp() almost always wants != 0 on it). So here's strstarts(). Cc: Anders Kaseorg <[email protected]> Cc: Jeff Arnold <[email protected]> Cc: Tim Abbott <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
2009-03-06vsprintf: add binary printfLai Jiangshan1-0/+7
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 [[email protected]: rebase] Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-11-02linux/string.h: fix comment typoJeff Garzik1-1/+1
s/user/used/ Signed-off-by: Jeff Garzik <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-07-24move memory_read_from_buffer() from fs.h to string.hAkinobu Mita1-0/+3
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 <[email protected]> Cc: James Bottomley <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Zhang Rui <[email protected]> Cc: Bob Moore <[email protected]> Cc: Thomas Renninger <[email protected]> Cc: Len Brown <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-05-01Add a new sysfs_streq() string comparison functionDavid Brownell1-0/+2
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 <[email protected]> Acked-by: Greg KH <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-10-30[TIPC]: Fix headercheck wrt. tipc_config.hDavid S. Miller1-9/+3
It wants string functions like memcpy() for inline routines, and these define userland interfaces. The only clean way to deal with this is to simply put linux/string.h into unifdef-y and have it include <string.h> when not-__KERNEL__. Signed-off-by: David S. Miller <[email protected]>
2007-07-18add argv_split()Jeremy Fitzhardinge1-0/+3
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 <[email protected]> Signed-off-by: Chris Wright <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Randy Dunlap <[email protected]>
2007-07-18add kstrndupJeremy Fitzhardinge1-0/+1
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 <[email protected]> Signed-off-by: Chris Wright <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: YOSHIFUJI Hideaki <[email protected]> Cc: Akinobu Mita <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Al Viro <[email protected]> Cc: Panagiotis Issaris <[email protected]> Cc: Rene Scharfe <[email protected]>
2007-04-26[STRING]: Move strcasecmp/strncasecmp to lib/string.cDavid S. Miller1-0/+6
We have several platforms using local copies of identical code. Signed-off-by: David S. Miller <[email protected]>
2006-10-01[PATCH] kmemdup: introduceAlexey Dobriyan1-0/+1
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-06-23[PATCH] strstrip() APIPekka Enberg1-0/+1
Add a new strstrip() function to lib/string.c for removing leading and trailing whitespace from a string. Cc: Michael Holzheu <[email protected]> Acked-by: Ingo Oeser <[email protected]> Acked-by: Joern Engel <[email protected]> Cc: Corey Minyard <[email protected]> Signed-off-by: Pekka Enberg <[email protected]> Acked-by: Michael Holzheu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-04-11[PATCH] Clean up arch-overrides in linux/string.hKyle McMartin1-5/+12
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-03-24[PATCH] strndup_user()Davi Arnaut1-0/+2
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 <[email protected]> Cc: David Howells <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2005-10-08[PATCH] gfp flags annotations - part 1Al Viro1-1/+1
- 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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2005-07-07[PATCH] propagate __nocast annotationsAlexey Dobriyan1-1/+1
Signed-off-by: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2005-06-23[PATCH] create a kstrdup library functionPaulo Marques1-0/+2
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2005-04-16Linux-2.6.12-rc2Linus Torvalds1-0/+96
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!