[PATCH 3/3] [GFS2] Prefer strlcpy() over snprintf()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: swhiteho
Date: Tuesday, May 20, 2008 - 2:12 am

From: Jean Delvare <khali@linux-fr.org>

strlcpy is faster than snprintf when you don't use the returned value.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index ef9c6c4..b2028c8 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -142,8 +142,8 @@ static int init_names(struct gfs2_sbd *sdp, int silent)
 	if (!table[0])
 		table = sdp->sd_vfs->s_id;
 
-	snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto);
-	snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table);
+	strlcpy(sdp->sd_proto_name, proto, GFS2_FSNAME_LEN);
+	strlcpy(sdp->sd_table_name, table, GFS2_FSNAME_LEN);
 
 	table = sdp->sd_table_name;
 	while ((table = strchr(table, '/')))
-- 
1.5.1.2

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GFS2] Pre-pull patch posting (bug fixes), swhiteho, (Tue May 20, 2:12 am)
[PATCH 3/3] [GFS2] Prefer strlcpy() over snprintf(), swhiteho, (Tue May 20, 2:12 am)
[GFS2] Pull request, Steven Whitehouse, (Tue May 20, 3:05 am)