arch: blackfin: kernel: using strlcpy instead of strncpy
PATCH 1/1 arch: blackfin: kernel: using strlcpy instead of strncpy
For NULL terminated string, need always be sure of ended by zero.
'command_line' is a static variable which will be initialized automatically, and cmdline_init() is __init function, so need not initialize it again, can just use strlcpy instead of strncpy.
--- arch/blackfin/kernel/setup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/blackfin/kernel/setup.c +1 -1
@@ -1458,5 +1458,5 @@ void __init cmdline_init(const char *r0) {early_shadow_stamp ();if (r0) -strncpy (command_line, r0,COMMAND_LINE_SIZE ); +strlcpy (command_line, r0,COMMAND_LINE_SIZE ); }
Signature · 1 line
1.7.7.6
Quoted 7 lines · Chen Gang
For NULL terminated string, need always be sure of ended by zero.
'
command_line' is a static variable which will be initialized automatically, andcmdline_init()is__initfunction, so need not initialize it again, can just use strlcpy instead of strncpy.
The 2nd paragraph comment is redundent, need delete. I will send patch v2.
Quoted 18 lines
Signed-off-by Chen Gang <[email protected]>--- arch/blackfin/kernel/setup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/blackfin/kernel/setup.c +1
-1@@ -1458,5 +1458,5 @@ void __init cmdline_init(const char *r0) {early_shadow_stamp ();if (r0) -strncpy (command_line, r0,COMMAND_LINE_SIZE ); +strlcpy (command_line, r0,COMMAND_LINE_SIZE ); }
Signature · 3 lines
Chen Gang Asianux Corporation
PATCH v2 1/1 arch: blackfin: kernel: using strlcpy() instead of strncpy()
In reply to Chen GangFor NULL terminated string, need always be sure of ended by zero.
Just use strlcpy() instead of strncpy().
--- arch/blackfin/kernel/setup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/blackfin/kernel/setup.c +1 -1
@@ -1458,5 +1458,5 @@ void __init cmdline_init(const char *r0) {early_shadow_stamp ();if (r0) -strncpy (command_line, r0,COMMAND_LINE_SIZE ); +strlcpy (command_line, r0,COMMAND_LINE_SIZE ); }
Signature · 1 line
1.7.7.6