提交 94c457de 编写于 作者: R Rickard Strandqvist 提交者: Helge Deller

parisc: pdc_stable.c: Cleaning up unnecessary use of memset in conjunction with strncpy

Using memset before strncpy just to ensure a trailing null character is
an unnecessary double writing of a string

Patch modified by Helge Deller to additionally reduce stack usage.
Signed-off-by: NRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: NHelge Deller <deller@gmx.de>
上级 fe5c8734
......@@ -755,7 +755,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
{
struct pdcspath_entry *pathentry;
unsigned char flags;
char in[count+1], *temp;
char in[8], *temp;
char c;
if (!capable(CAP_SYS_ADMIN))
......@@ -765,8 +765,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
return -EINVAL;
/* We'll use a local copy of buf */
memset(in, 0, count+1);
count = min_t(size_t, count, 7);
strncpy(in, buf, count);
in[count] = '\0';
/* Current flags are stored in primary boot path entry */
pathentry = &pdcspath_entry_primary;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册