Skip to content

Commit

Permalink
parisc: pdc_stable.c: Cleaning up unnecessary use of memset in conjun…
Browse files Browse the repository at this point in the history
…ction 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>
  • Loading branch information
Rickard Strandqvist authored and Helge Deller committed Sep 21, 2014
1 parent fe5c873 commit 94c457d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/parisc/pdc_stable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
Expand Down

0 comments on commit 94c457d

Please sign in to comment.