All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parisc: pdc_stable.c:  Cleaning up unnecessary use of memset in conjunction with strncpy
@ 2014-09-14 16:02 Rickard Strandqvist
  2014-09-22 18:24 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-09-14 16:02 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller
  Cc: Rickard Strandqvist, linux-parisc, linux-kernel

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

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/parisc/pdc_stable.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 0f54ab6..76860ad 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -765,8 +765,8 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
 		return -EINVAL;
 
 	/* We'll use a local copy of buf */
-	memset(in, 0, count+1);
 	strncpy(in, buf, count);
+	in[count] = '\0';
 
 	/* Current flags are stored in primary boot path entry */
 	pathentry = &pdcspath_entry_primary;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-22 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14 16:02 [PATCH] parisc: pdc_stable.c: Cleaning up unnecessary use of memset in conjunction with strncpy Rickard Strandqvist
2014-09-22 18:24 ` Helge Deller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.