Skip to content

Commit 94c457d

Browse files
Rickard Strandqvisthdeller
authored andcommitted
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: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent fe5c873 commit 94c457d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/parisc/pdc_stable.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
755755
{
756756
struct pdcspath_entry *pathentry;
757757
unsigned char flags;
758-
char in[count+1], *temp;
758+
char in[8], *temp;
759759
char c;
760760

761761
if (!capable(CAP_SYS_ADMIN))
@@ -765,8 +765,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
765765
return -EINVAL;
766766

767767
/* We'll use a local copy of buf */
768-
memset(in, 0, count+1);
768+
count = min_t(size_t, count, 7);
769769
strncpy(in, buf, count);
770+
in[count] = '\0';
770771

771772
/* Current flags are stored in primary boot path entry */
772773
pathentry = &pdcspath_entry_primary;

0 commit comments

Comments
 (0)