public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: lustre: libcfs: debug.c:  Cleaning up unnecessary use of memset in conjunction with strncpy
@ 2014-09-14 16:03 Rickard Strandqvist
  2014-09-15  8:23 ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Rickard Strandqvist @ 2014-09-14 16:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Peng Tao; +Cc: Rickard Strandqvist, devel, 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/staging/lustre/lustre/libcfs/debug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 6b58469..98c7c3a 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -402,9 +402,9 @@ int libcfs_debug_init(unsigned long bufsize)
 	}
 
 	if (libcfs_debug_file_path != NULL) {
-		memset(libcfs_debug_file_path_arr, 0, PATH_MAX);
 		strncpy(libcfs_debug_file_path_arr,
 			libcfs_debug_file_path, PATH_MAX-1);
+		libcfs_debug_file_path_arr[PATH_MAX - 1] = '\0';
 	}
 
 	/* If libcfs_debug_mb is set to an invalid value or uninitialized
-- 
1.7.10.4


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

end of thread, other threads:[~2014-10-14 21:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14 16:03 [PATCH] staging: lustre: lustre: libcfs: debug.c: Cleaning up unnecessary use of memset in conjunction with strncpy Rickard Strandqvist
2014-09-15  8:23 ` Dan Carpenter
2014-09-17 22:12   ` Rickard Strandqvist
2014-09-18  8:51     ` Dan Carpenter
2014-09-18 19:57       ` Rickard Strandqvist
2014-09-18 22:39         ` Dan Carpenter
2014-10-14 21:34           ` Rickard Strandqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox