Skip to contentSkip to conversation

fs/ntfs3: Remove unnecessary condition checking from ntfs_file_read_iter

PATCH Applied Kari Argillander 3 participants 4 messages Aug 25, 2021 – Sep 2, 2021 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ntfs3: Remove unnecessary condition checking from ntfs_file_read_iter

This check will be also performed in generic_file_read_iter() so we do not want to check this two times in a row.

This was founded with Smatch

	fs/ntfs3/file.c:803 ntfs_file_read_iter()
	warn: unused return: count = iov_iter_count()

---
I cc Dan also because I am happy that I finally managed to install Smack and straight away I found something with it. Thank you for this great tool.

Next step is to integrate Smack to CI system. But will probanly take a moment.

---
 fs/ntfs3/file.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/ntfs3/file.c +1 -5
index cb736701f2cc..5d41b84067ee 100644
@@ -799,8 +799,6 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 
 static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 {
-	ssize_t err;
-	size_t count = iov_iter_count(iter);
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct ntfs_inode *ni = ntfs_i(inode);
@@ -829,9 +827,7 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 		return -EOPNOTSUPP;
 	}
 
-	err = count ? generic_file_read_iter(iocb, iter) : 0;
-
-	return err;
+	return generic_file_read_iter(iocb, iter);
 }
 
 /* returns array of locked pages */
Signature · 1 line
2.30.2
#1 lore raw
Quoted 4 lines · Kari Argillander

This check will be also performed in generic_file_read_iter() so we do not want to check this two times in a row.

This was founded with Smatch

Quoted 8 lines
	fs/ntfs3/file.c:803 ntfs_file_read_iter()
	warn: unused return: count = iov_iter_count()

---
I cc Dan also because I am happy that I finally managed to install Smack and straight away I found something with it. Thank you for this great tool.

Thanks!

You got a bit lucky, because you're using the --two-passes and the truth is I haven't looked at that in years so I'm worried it's probably not great. You probably be better off not using the --two-passes option. :/ I should remove it.

regards,
dan carpenter

#2 lore raw
Quoted 14 lines · Dan Carpenter
Quoted 4 lines · Kari Argillander

This check will be also performed in generic_file_read_iter() so we do not want to check this two times in a row.

This was founded with Smatch

Quoted 8 lines
	fs/ntfs3/file.c:803 ntfs_file_read_iter()
	warn: unused return: count = iov_iter_count()

---
I cc Dan also because I am happy that I finally managed to install Smack and straight away I found something with it. Thank you for this great tool.

Quoted 6 lines

Thanks!

You got a bit lucky, because you're using the --two-passes and the truth is I haven't looked at that in years so I'm worried it's probably not great. You probably be better off not using the --two-passes option. :/ I should remove it.

Haha no I need it :D I was just testing what this tool can do. I also notice that --two-passes seems quite bad to read. But hey I found something! :D Good to know that you are not using it. I will not use it then. Thanks.

Quoted 5 lines

regards,
dan carpenter

maintainer Applied
#3 lore raw
In reply to Kari Argillander
Quoted 34 lines · Kari Argillander

This check will be also performed in generic_file_read_iter() so we do not want to check this two times in a row.

This was founded with Smatch

	fs/ntfs3/file.c:803 ntfs_file_read_iter()
	warn: unused return: count = iov_iter_count()

---
I cc Dan also because I am happy that I finally managed to install Smack and straight away I found something with it. Thank you for this great tool.

Next step is to integrate Smack to CI system. But will probanly take a moment.

---
 fs/ntfs3/file.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/ntfs3/file.c +0 -2
index cb736701f2cc..5d41b84067ee 100644
@@ -799,8 +799,6 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 
 static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 {
-	ssize_t err;
-	size_t count = iov_iter_count(iter);
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct ntfs_inode *ni = ntfs_i(inode);

fs/ntfs3/file.c static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) · line 833

Quoted 10 lines
fs/ntfs3/file.c +1 -3
@@ -829,9 +827,7 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 		return -EOPNOTSUPP;
 	}
 
-	err = count ? generic_file_read_iter(iocb, iter) : 0;
-
-	return err;
+	return generic_file_read_iter(iocb, iter);
 }
 
 /* returns array of locked pages */

Applied, thanks!