Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 3/3] exfat: replace memcpy with structure assignment
@ 2020-09-11 4:45 ` Tetsuhiro Kohada
2020-09-16 2:23 ` Sungjong Seo
0 siblings, 1 reply; 3+ messages in thread
From: Tetsuhiro Kohada @ 2020-09-11 4:45 UTC (permalink / raw)
To: kohada.t2
Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka, Namjae Jeon,
Sungjong Seo, linux-fsdevel, linux-kernel
Use structure assignment instead of memcpy.
Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
---
fs/exfat/dir.c | 7 ++-----
fs/exfat/inode.c | 2 +-
fs/exfat/namei.c | 15 +++++++--------
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index fa5bb72aa295..8520decd120c 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -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);
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 70a33d4807c3..687f77653187 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -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;
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 1c433491f771..2932b23a3b6c 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -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);
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH 3/3] exfat: replace memcpy with structure assignment
2020-09-11 4:45 ` [PATCH 3/3] exfat: replace memcpy with structure assignment Tetsuhiro Kohada
@ 2020-09-16 2:23 ` Sungjong Seo
2020-09-21 5:51 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Sungjong Seo @ 2020-09-16 2:23 UTC (permalink / raw)
To: 'Tetsuhiro Kohada'
Cc: kohada.tetsuhiro, mori.takahiro, motai.hirotaka,
'Namjae Jeon',
linux-fsdevel, linux-kernel
> Use structure assignment instead of memcpy.
>
> Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
> ---
> fs/exfat/dir.c | 7 ++-----
> fs/exfat/inode.c | 2 +-
> fs/exfat/namei.c | 15 +++++++--------
> 3 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index
> fa5bb72aa295..8520decd120c 100644
> --- a/fs/exfat/dir.c
> +++ b/fs/exfat/dir.c
> @@ -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);
> diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index
> 70a33d4807c3..687f77653187 100644
> --- a/fs/exfat/inode.c
> +++ b/fs/exfat/inode.c
> @@ -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;
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index
> 1c433491f771..2932b23a3b6c 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -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);
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3/3] exfat: replace memcpy with structure assignment
2020-09-16 2:23 ` Sungjong Seo
@ 2020-09-21 5:51 ` Namjae Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2020-09-21 5:51 UTC (permalink / raw)
To: Tetsuhiro Kohada
Cc: Sungjong Seo, kohada.tetsuhiro, mori.takahiro, motai.hirotaka,
Namjae Jeon, linux-fsdevel, linux-kernel
2020-09-15 19:23 GMT-07:00, Sungjong Seo <sj1557.seo@samsung.com>:
>> Use structure assignment instead of memcpy.
>>
>> Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
>
> Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
Applied. Thanks for your patch!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-21 5:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20200911044525epcas1p4a050411f3049c625b81c7d6516982537@epcas1p4.samsung.com>
2020-09-11 4:45 ` [PATCH 3/3] exfat: replace memcpy with structure assignment Tetsuhiro Kohada
2020-09-16 2:23 ` Sungjong Seo
2020-09-21 5:51 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).