diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-02-10 14:35:36 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-02-10 14:35:36 -0500 |
commit | 4ba24fef3eb3b142197135223b90ced2f319cd53 (patch) | |
tree | a20c125b27740ec7b4c761b11d801108e1b316b2 /lib/string.c | |
parent | 47c1ffb2b6b630894e9a16442611c056ab21c057 (diff) | |
parent | 98a4a59ee31a12105a2b84f5b8b515ac2cb208ef (diff) |
Merge branch 'next' into for-linus
Prepare first round of input updates for 3.20.
Diffstat (limited to 'lib/string.c')
-rw-r--r-- | lib/string.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/lib/string.c b/lib/string.c index f3c6ff596414..10063300b830 100644 --- a/lib/string.c +++ b/lib/string.c | |||
@@ -27,14 +27,14 @@ | |||
27 | #include <linux/bug.h> | 27 | #include <linux/bug.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | 29 | ||
30 | #ifndef __HAVE_ARCH_STRNICMP | 30 | #ifndef __HAVE_ARCH_STRNCASECMP |
31 | /** | 31 | /** |
32 | * strnicmp - Case insensitive, length-limited string comparison | 32 | * strncasecmp - Case insensitive, length-limited string comparison |
33 | * @s1: One string | 33 | * @s1: One string |
34 | * @s2: The other string | 34 | * @s2: The other string |
35 | * @len: the maximum number of characters to compare | 35 | * @len: the maximum number of characters to compare |
36 | */ | 36 | */ |
37 | int strnicmp(const char *s1, const char *s2, size_t len) | 37 | int strncasecmp(const char *s1, const char *s2, size_t len) |
38 | { | 38 | { |
39 | /* Yes, Virginia, it had better be unsigned */ | 39 | /* Yes, Virginia, it had better be unsigned */ |
40 | unsigned char c1, c2; | 40 | unsigned char c1, c2; |
@@ -56,6 +56,14 @@ int strnicmp(const char *s1, const char *s2, size_t len) | |||
56 | } while (--len); | 56 | } while (--len); |
57 | return (int)c1 - (int)c2; | 57 | return (int)c1 - (int)c2; |
58 | } | 58 | } |
59 | EXPORT_SYMBOL(strncasecmp); | ||
60 | #endif | ||
61 | #ifndef __HAVE_ARCH_STRNICMP | ||
62 | #undef strnicmp | ||
63 | int strnicmp(const char *s1, const char *s2, size_t len) | ||
64 | { | ||
65 | return strncasecmp(s1, s2, len); | ||
66 | } | ||
59 | EXPORT_SYMBOL(strnicmp); | 67 | EXPORT_SYMBOL(strnicmp); |
60 | #endif | 68 | #endif |
61 | 69 | ||
@@ -73,20 +81,6 @@ int strcasecmp(const char *s1, const char *s2) | |||
73 | EXPORT_SYMBOL(strcasecmp); | 81 | EXPORT_SYMBOL(strcasecmp); |
74 | #endif | 82 | #endif |
75 | 83 | ||
76 | #ifndef __HAVE_ARCH_STRNCASECMP | ||
77 | int strncasecmp(const char *s1, const char *s2, size_t n) | ||
78 | { | ||
79 | int c1, c2; | ||
80 | |||
81 | do { | ||
82 | c1 = tolower(*s1++); | ||
83 | c2 = tolower(*s2++); | ||
84 | } while ((--n > 0) && c1 == c2 && c1 != 0); | ||
85 | return c1 - c2; | ||
86 | } | ||
87 | EXPORT_SYMBOL(strncasecmp); | ||
88 | #endif | ||
89 | |||
90 | #ifndef __HAVE_ARCH_STRCPY | 84 | #ifndef __HAVE_ARCH_STRCPY |
91 | /** | 85 | /** |
92 | * strcpy - Copy a %NUL terminated string | 86 | * strcpy - Copy a %NUL terminated string |
@@ -604,6 +598,22 @@ void *memset(void *s, int c, size_t count) | |||
604 | EXPORT_SYMBOL(memset); | 598 | EXPORT_SYMBOL(memset); |
605 | #endif | 599 | #endif |
606 | 600 | ||
601 | /** | ||
602 | * memzero_explicit - Fill a region of memory (e.g. sensitive | ||
603 | * keying data) with 0s. | ||
604 | * @s: Pointer to the start of the area. | ||
605 | * @count: The size of the area. | ||
606 | * | ||
607 | * memzero_explicit() doesn't need an arch-specific version as | ||
608 | * it just invokes the one of memset() implicitly. | ||
609 | */ | ||
610 | void memzero_explicit(void *s, size_t count) | ||
611 | { | ||
612 | memset(s, 0, count); | ||
613 | OPTIMIZER_HIDE_VAR(s); | ||
614 | } | ||
615 | EXPORT_SYMBOL(memzero_explicit); | ||
616 | |||
607 | #ifndef __HAVE_ARCH_MEMCPY | 617 | #ifndef __HAVE_ARCH_MEMCPY |
608 | /** | 618 | /** |
609 | * memcpy - Copy one area of memory to another | 619 | * memcpy - Copy one area of memory to another |