exfat: replace memcpy with structure assignment
Subsystems (2)
PATCH 3/3 exfat: replace memcpy with structure assignment
Use structure assignment instead of memcpy.
Signed-off-by Tetsuhiro Kohada <[email protected]>
--- fs/exfat/dir.c | 7 ++----- fs/exfat/inode.c | 2 +- fs/exfat/namei.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 14 deletions(-)
fs/exfat/dir.c +2 -5
@@ -974,11 +974,8 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,if (ei->hint_femp.eidx ==EXFAT_HINT_NONE || candi_empty.eidx <= - ei->hint_femp.eidx) { -memcpy (&ei->hint_femp, - &candi_empty, -sizeof (candi_empty)); - } + ei->hint_femp.eidx) + ei->hint_femp = candi_empty; }brelse (bh);
fs/exfat/inode.c +1 -1
@@ -554,7 +554,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)struct exfat_inode_info *ei =EXFAT_I (inode);loff_t size = info->size; -memcpy (&ei->dir, &info->dir,sizeof (struct exfat_chain )); + ei->dir = info->dir; ei->entry = info->entry; ei->attr = info->attr; ei->start_clu = info->start_clu;
fs/exfat/namei.c +7 -8
@@ -318,8 +318,7 @@ static int exfat_find_empty_entry(struct inode *inode, hint_femp.eidx =EXFAT_HINT_NONE ;if (ei->hint_femp.eidx !=EXFAT_HINT_NONE ) { -memcpy (&hint_femp, &ei->hint_femp, -sizeof (struct exfat_hint_femp )); + hint_femp = ei->hint_femp; ei->hint_femp.eidx =EXFAT_HINT_NONE ; }
@@ -519,7 +518,7 @@ static int exfat_add_entry(struct inode *inode, const char *path,if (ret) goto out; -memcpy (&info->dir, p_dir,sizeof (struct exfat_chain )); + info->dir = *p_dir; info->entry = dentry; info->flags =ALLOC_NO_FAT_CHAIN ; info->type = type;
@@ -625,7 +624,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname,if (dentry <0 )return dentry;/* -error value */ -memcpy (&info->dir, &cdir.dir,sizeof (struct exfat_chain )); + info->dir = cdir; info->entry = dentry; info->num_subdirs =0 ;
@@ -1030,7 +1029,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,if (!epnew)return -EIO ; -memcpy (epnew, epold,DENTRY_SIZE ); + *epnew = *epold;if (exfat_get_entry_type (epnew) ==TYPE_FILE ) { epnew->dentry.file.attr |=cpu_to_le16 (ATTR_ARCHIVE ); ei->attr |=ATTR_ARCHIVE ;
@@ -1050,7 +1049,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,return -EIO ; } -memcpy (epnew, epold,DENTRY_SIZE ); + *epnew = *epold;exfat_update_bh (new_bh, sync);brelse (old_bh);brelse (new_bh);
@@ -1113,7 +1112,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,if (!epnew)return -EIO ; -memcpy (epnew, epmov,DENTRY_SIZE ); + *epnew = *epmov;if (exfat_get_entry_type (epnew) ==TYPE_FILE ) { epnew->dentry.file.attr |=cpu_to_le16 (ATTR_ARCHIVE ); ei->attr |=ATTR_ARCHIVE ;
@@ -1133,7 +1132,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,return -EIO ; } -memcpy (epnew, epmov,DENTRY_SIZE ); + *epnew = *epmov;exfat_update_bh (new_bh,IS_DIRSYNC (inode));brelse (mov_bh);brelse (new_bh);
Signature · 1 line
2.25.1
Quoted 3 lines
Use structure assignment instead of memcpy.
Signed-off-by Tetsuhiro Kohada <[email protected]>
Acked-by Sungjong Seo <[email protected]>
Quoted 11 lines
--- fs/exfat/dir.c | 7 ++----- fs/exfat/inode.c | 2 +- fs/exfat/namei.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 14 deletions(-)fs/exfat/dir.c index renamed from fs/exfat/dir.c +0
-0
fa5bb72aa295..8520decd120c100644
fs/exfat/dir.c int exfat_find_dir_entry(struct super_block *sb, · line 978
Quoted 5 lines
fs/exfat/dir.c +0
-1@@ -974,11 +974,8 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei, if (ei->hint_femp.eidx == EXFAT_HINT_NONE || candi_empty.eidx <= - ei->hint_femp.eidx)
{
fs/exfat/dir.c int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
Quoted 3 lines
fs/exfat/dir.c +0
-3- memcpy(&ei->hint_femp, - &candi_empty, -
sizeof(candi_empty));
Quoted 55 lines
fs/exfat/dir.c +2
-1- } + ei->hint_femp.eidx) + ei->hint_femp = candi_empty; }fs/exfat/dir.c +0
-0brelse (bh);fs/exfat/inode.c index renamed from fs/exfat/inode.c +0
-0
70a33d4807c3..687f77653187100644fs/exfat/inode.c +1
-1@@ -554,7 +554,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)struct exfat_inode_info *ei =EXFAT_I (inode);loff_t size = info->size; -memcpy (&ei->dir, &info->dir,sizeof (struct exfat_chain )); + ei->dir = info->dir; ei->entry = info->entry; ei->attr = info->attr;fs/exfat/inode.c +0
-0ei->start_clu = info->start_clu;fs/exfat/namei.c index renamed from fs/exfat/namei.c +0
-0
1c433491f771..2932b23a3b6c100644fs/exfat/namei.c +2
-3@@ -318,8 +318,7 @@ static int exfat_find_empty_entry(struct inode *inode, hint_femp.eidx =EXFAT_HINT_NONE ;if (ei->hint_femp.eidx !=EXFAT_HINT_NONE ) { -memcpy (&hint_femp, &ei->hint_femp, -sizeof (struct exfat_hint_femp )); + hint_femp = ei->hint_femp; ei->hint_femp.eidx =EXFAT_HINT_NONE ; }@@ -519,7 +518,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, if (ret) goto out; -memcpy (&info->dir, p_dir,sizeof (struct exfat_chain )); + info->dir = *p_dir; info->entry = dentry; info->flags =ALLOC_NO_FAT_CHAIN ;fs/exfat/namei.c +1
-1info->type = type;@@ -625,7 +624,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname, if (dentry < 0)return dentry;/* -error value */ -memcpy (&info->dir, &cdir.dir,sizeof (struct exfat_chain )); + info->dir = cdir; info->entry = dentry; info->num_subdirs =0 ;
fs/exfat/namei.c static int exfat_rename_file(struct inode *inode, · line 1035
Quoted 8 lines
fs/exfat/namei.c +1
-1@@ -1030,7 +1029,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, if (!epnew) return -EIO; -memcpy (epnew, epold,DENTRY_SIZE ); + *epnew = *epold;if (exfat_get_entry_type (epnew) ==TYPE_FILE ) { epnew->dentry.file.attr |=
cpu_to_le16(ATTR_ARCHIVE);
Quoted 33 lines
fs/exfat/namei.c +1
-1ei->attr |=ATTR_ARCHIVE ;@@ -1050,7 +1049,7 @@ static int exfat_rename_file(struct inode *inode,struct exfat_chain *p_dir, return -EIO; } -memcpy (epnew, epold,DENTRY_SIZE ); + *epnew = *epold;exfat_update_bh (new_bh, sync);brelse (old_bh);fs/exfat/namei.c +1
-1brelse (new_bh);@@ -1113,7 +1112,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (!epnew) return -EIO; -memcpy (epnew, epmov,DENTRY_SIZE ); + *epnew = *epmov;if (exfat_get_entry_type (epnew) ==TYPE_FILE ) { epnew->dentry.file.attr |=cpu_to_le16 (ATTR_ARCHIVE );fs/exfat/namei.c +1
-1ei->attr |=ATTR_ARCHIVE ;@@ -1133,7 +1132,7 @@ static int exfat_move_file(struct inode *inode,struct exfat_chain *p_olddir, return -EIO; } -memcpy (epnew, epmov,DENTRY_SIZE ); + *epnew = *epmov;exfat_update_bh (new_bh,IS_DIRSYNC (inode));brelse (mov_bh);
brelse(new_bh);
--
2.25.1
2020-09-15 19:23 GMT-07:00, Sungjong Seo <[email protected]>:
Quoted 5 lines
Quoted 3 lines
Use structure assignment instead of memcpy.
Signed-off-by Tetsuhiro Kohada <[email protected]>Acked-by Sungjong Seo <[email protected]>
Applied. Thanks for your patch!