OSDN Git Service

soc: qcom: glink_debugfs: Fix strlcpy usage
authorNathan Chancellor <natechancellor@gmail.com>
Fri, 27 Sep 2019 06:23:54 +0000 (23:23 -0700)
committerNathan Chancellor <natechancellor@gmail.com>
Fri, 27 Sep 2019 07:42:38 +0000 (00:42 -0700)
Clang warns:

../drivers/soc/qcom/glink_debugfs.c:562:18: warning: size argument in
'strlcpy' call appears to be size of the source; expected the size of
the destination [-Wstrlcpy-strlcat-size]
                                curr, strlen(curr) + 1);
                                      ~~~~~~~^~~~~~~~~
../drivers/soc/qcom/glink_debugfs.c:562:11: note: change size argument
to be the size of the destination
                                curr, strlen(curr) + 1);
                                      ^~~~~~~~~~~~~~~~
                                      sizeof(dbgfs_dent_s->self_name)
../drivers/soc/qcom/glink_debugfs.c:564:13: warning: size argument in
'strlcpy' call appears to be size of the source; expected the size of
the destination [-Wstrlcpy-strlcat-size]
                                        strlen(par_dir) + 1);
                                        ~~~~~~~^~~~~~~~~~~~
../drivers/soc/qcom/glink_debugfs.c:564:6: note: change size argument to
be the size of the destination
                                        strlen(par_dir) + 1);
                                        ^~~~~~~~~~~~~~~~~~~
                                        sizeof(dbgfs_dent_s->par_name)
2 warnings generated.

Fixes: 987bbebd9aa6 ("soc: qcom: Add snapshot of G-Link driver")
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
drivers/soc/qcom/glink_debugfs.c

index 8e65e4a..62d6817 100644 (file)
@@ -558,10 +558,10 @@ void glink_dfs_update_list(struct dentry *curr_dent, struct dentry *parent,
                        spin_lock_init(&dbgfs_dent_s->file_list_lock_lhb0);
                        dbgfs_dent_s->parent = parent;
                        dbgfs_dent_s->self = curr_dent;
-                       strlcpy(dbgfs_dent_s->self_name,
-                               curr, strlen(curr) + 1);
-                       strlcpy(dbgfs_dent_s->par_name, par_dir,
-                                       strlen(par_dir) + 1);
+                       strscpy(dbgfs_dent_s->self_name, curr,
+                               sizeof(dbgfs_dent_s->self_name));
+                       strscpy(dbgfs_dent_s->par_name, par_dir,
+                               sizeof(dbgfs_dent_s->par_name));
                        mutex_lock(&dent_list_lock_lha0);
                        list_add_tail(&dbgfs_dent_s->list_node, &dent_list);
                        mutex_unlock(&dent_list_lock_lha0);