kernel.h: Move lib/cmdline.c prototypes to string.h
PATCH 1/1 kernel.h: Move lib/cmdline.c prototypes to string.h
The lib/cmdline.c is basically a set of some small string parsers which are wide used in the kernel. Their prototypes belong to the string.h rather then kernel.h.
--- include/linux/kernel.h | 6 ------ include/linux/string.h | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-)
include/linux/kernel.h +0 -6
@@ -195,12 +195,6 @@ static inline void might_fault(void) { }void do_exit (long error_code)__noreturn ; -extern int get_option (char **str,int *pint); -extern char *get_options (const char *str,int nints,int *ints); -extern unsigned long long memparse (const char *ptr,char **retptr); -extern bool parse_option_str (const char *str,const char *option); -extern char *next_arg (char *args,char **param,char **val); -extern int core_kernel_text (unsigned long addr);extern int __kernel_text_address (unsigned long addr);extern int kernel_text_address (unsigned long addr);
include/linux/string.h +8 -0
@@ -181,9 +181,17 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);extern void *kvmemdup (const void *src,size_t len,gfp_t gfp)__realloc_size (2 );extern char *kmemdup_nul (const char *s,size_t len,gfp_t gfp); +/* lib/argv_split.c */ extern char **argv_split (gfp_t gfp,const char *str,int *argcp);extern void argv_free (char **argv); +/* lib/cmdline.c */ +extern int get_option (char **str,int *pint); +extern char *get_options (const char *str,int nints,int *ints); +extern unsigned long long memparse (const char *ptr,char **retptr); +extern bool parse_option_str (const char *str,const char *option); +extern char *next_arg (char *args,char **param,char **val); +extern bool sysfs_streq (const char *s1,const char *s2);int match_string (const char *const *array,size_t n,const char *string);int __sysfs_match_string (const char *const *array,size_t n,const char *s);
Signature · 1 line
2.40.0.1.gaa8946217a0b
Quoted 5 lines · Andy Shevchenko
The
lib/cmdline.cis basically a set of some small string parsers which are wide used in the kernel. Their prototypes belong to thestring.hrather thenkernel.h.Signed-off-by Andy Shevchenko <[email protected]>
I think these should live in string_helpers.h not string.h (which is, in theory, supposed to be used for the standard C string library functions, though that's not 100% currently)...
-Kees
Quoted 47 lines
--- include/linux/kernel.h | 6 ------ include/linux/string.h | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-)include/linux/kernel.h +0
-6@@ -195,12 +195,6 @@ static inline void might_fault(void) { }void do_exit (long error_code)__noreturn ; -extern int get_option (char **str,int *pint); -extern char *get_options (const char *str,int nints,int *ints); -extern unsigned long long memparse (const char *ptr,char **retptr); -extern bool parse_option_str (const char *str,const char *option); -extern char *next_arg (char *args,char **param,char **val); -extern int core_kernel_text (unsigned long addr);extern int __kernel_text_address (unsigned long addr);extern int kernel_text_address (unsigned long addr);include/linux/string.h +8
-0@@ -181,9 +181,17 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);extern void *kvmemdup (const void *src,size_t len,gfp_t gfp)__realloc_size (2 );extern char *kmemdup_nul (const char *s,size_t len,gfp_t gfp); +/* lib/argv_split.c */ extern char **argv_split (gfp_t gfp,const char *str,int *argcp);extern void argv_free (char **argv); +/* lib/cmdline.c */ +extern int get_option (char **str,int *pint); +extern char *get_options (const char *str,int nints,int *ints); +extern unsigned long long memparse (const char *ptr,char **retptr); +extern bool parse_option_str (const char *str,const char *option); +extern char *next_arg (char *args,char **param,char **val); +extern bool sysfs_streq (const char *s1,const char *s2);int match_string (const char *const *array,size_t n,const char *string);int __sysfs_match_string (const char *const *array,size_t n,const char *s);Signature · 1 line
2.40.0.1.gaa8946217a0b
Signature · 1 line
Kees Cook
Quoted 11 lines · Kees Cook
Quoted 5 lines · Andy Shevchenko
The
lib/cmdline.cis basically a set of some small string parsers which are wide used in the kernel. Their prototypes belong to thestring.hrather thenkernel.h.Signed-off-by Andy Shevchenko <[email protected]>I think these should live in
string_helpers.hnotstring.h(which is, in theory, supposed to be used for the standard C string library functions, though that's not 100% currently)...
These are being used in the early stages where usually we have string.h. So, I would argue, but if you insist, I can move them. What about lib/argv_slit.c then? Because semantically it's quite close to what the lib/cmdline.c is doing.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Kees Cook
Quoted 3 lines · Andy Shevchenko
The
lib/cmdline.cis basically a set of some small string parsers which are wide used in the kernel. Their prototypes belong to thestring.hrather thenkernel.h.
Quoted 8 lines
Quoted 3 lines
I think these should live in
string_helpers.hnotstring.h(which is, in theory, supposed to be used for the standard C string library functions, though that's not 100% currently)...These are being used in the early stages where usually we have
string.h. So, I would argue, but if you insist, I can move them. What aboutlib/argv_slit.cthen? Because semantically it's quite close to what thelib/cmdline.cis doing.
So, if no further ARs, can we got this applied and move on?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Kees Cook
AppliedQuoted 3 lines · Andy Shevchenko
The
lib/cmdline.cis basically a set of some small string parsers which are wide used in the kernel. Their prototypes belong to thestring.hrather thenkernel.h.
Applied to for-next/hardening, thanks!
[1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
https://git.kernel.org/kees/c/9f938458a5dd
Take care,
Signature · 1 line
Kees Cook