Skip to contentSkip to conversation

arch: blackfin: kernel: using strlcpy instead of strncpy

PATCH In review Chen Gang 1 participant 3 messages May 26, 2013 – May 27, 2013 Generic include/asm header files

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

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
index 107b306..c731ec7 100644
@@ -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
author
#1 lore raw
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, and cmdline_init() is __init function, 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
---
 arch/blackfin/kernel/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/blackfin/kernel/setup.c +1 -1
index 107b306..c731ec7 100644
@@ -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
author
#2 lore raw

PATCH v2 1/1 arch: blackfin: kernel: using strlcpy() instead of strncpy()

In reply to Chen Gang

For 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
index 107b306..c731ec7 100644
@@ -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