aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parisc
diff options
context:
space:
mode:
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>2014-09-14 12:02:12 -0400
committerHelge Deller <deller@gmx.de>2014-09-21 15:07:48 -0400
commit94c457deff2a211f8372f69a4d7b0d288183756a (patch)
tree3c697069758c133e549a76f899ebfc6fd89cb5e2 /drivers/parisc
parentfe5c873459a973e59854bd235a7e6b3eaa8e5fe0 (diff)
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>
Diffstat (limited to 'drivers/parisc')
-rw-r--r--drivers/parisc/pdc_stable.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 0f54ab6260df..e4b73c2a053a 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -755,7 +755,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
755{ 755{
756 struct pdcspath_entry *pathentry; 756 struct pdcspath_entry *pathentry;
757 unsigned char flags; 757 unsigned char flags;
758 char in[count+1], *temp; 758 char in[8], *temp;
759 char c; 759 char c;
760 760
761 if (!capable(CAP_SYS_ADMIN)) 761 if (!capable(CAP_SYS_ADMIN))
@@ -765,8 +765,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
765 return -EINVAL; 765 return -EINVAL;
766 766
767 /* We'll use a local copy of buf */ 767 /* We'll use a local copy of buf */
768 memset(in, 0, count+1); 768 count = min_t(size_t, count, 7);
769 strncpy(in, buf, count); 769 strncpy(in, buf, count);
770 in[count] = '\0';
770 771
771 /* Current flags are stored in primary boot path entry */ 772 /* Current flags are stored in primary boot path entry */
772 pathentry = &pdcspath_entry_primary; 773 pathentry = &pdcspath_entry_primary;