locking/lockdep: Replace snprintf with strscpy in seq_stats
PATCH 1/1 locking/lockdep: Replace snprintf with strscpy in seq_stats
Replace snprintf("%s", ...) with the faster and more direct strscpy().
Signed-off-by Thorsten Blum <[email protected]>
--- kernel/locking/lockdep_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/locking/lockdep_proc.c +3 -2
@@ -19,6 +19,7 @@#include <linux/debug_locks.h> #include <linux/vmalloc.h> #include <linux/sort.h> +#include <linux/string.h> #include <linux/uaccess.h> #include <asm/div64.h>
@@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)const char *key_name; key_name =__get_key_name (ckey, str); -snprintf (name, namelen,"%s" , key_name); +strscpy (name, key_name, namelen); }else { -snprintf (name, namelen,"%s" , cname); +strscpy (name, cname, namelen); }rcu_read_unlock_sched ();
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Quoted 21 lines · Thorsten Blum
Replace
snprintf("%s", ...)with the faster and more directstrscpy().Signed-off-by Thorsten Blum <[email protected]>--- kernel/locking/lockdep_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/locking/lockdep_proc.c +1
-0@@ -19,6 +19,7 @@#include <linux/debug_locks.h> #include <linux/vmalloc.h> #include <linux/sort.h> +#include <linux/string.h> #include <linux/uaccess.h> #include <asm/div64.h> @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)const char *key_name;
kernel/locking/lockdep_proc.c static void seq_stats(struct seq_file *m, struct lock_stat_data *data) · line 497
Quoted 10 lines
kernel/locking/lockdep_proc.c +2
-2key_name =__get_key_name (ckey, str); -snprintf (name, namelen,"%s" , key_name); +strscpy (name, key_name, namelen); }else { -snprintf (name, namelen,"%s" , cname); +strscpy (name, cname, namelen); }rcu_read_unlock_sched ();
Reviewed-by Waiman Long <[email protected]>