Skip to content

Commit 58eeba0

Browse files
mellanoxbmcandy-shev
authored andcommitted
lib/string_helpers: Introduce string_upper() and string_lower() helpers
Provide the helpers for string conversions to upper and lower cases. Signed-off-by: Vadim Pasternak <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 19206a1 commit 58eeba0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/linux/string_helpers.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _LINUX_STRING_HELPERS_H_
33
#define _LINUX_STRING_HELPERS_H_
44

5+
#include <linux/ctype.h>
56
#include <linux/types.h>
67

78
struct file;
@@ -75,6 +76,20 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
7576
return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
7677
}
7778

79+
static inline void string_upper(char *dst, const char *src)
80+
{
81+
do {
82+
*dst++ = toupper(*src);
83+
} while (*src++);
84+
}
85+
86+
static inline void string_lower(char *dst, const char *src)
87+
{
88+
do {
89+
*dst++ = tolower(*src);
90+
} while (*src++);
91+
}
92+
7893
char *kstrdup_quotable(const char *src, gfp_t gfp);
7994
char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp);
8095
char *kstrdup_quotable_file(struct file *file, gfp_t gfp);

0 commit comments

Comments
 (0)