Linux-ext4 Archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: extents: Modify the return value variable type and initialize the assignment
@ 2023-02-08 19:34 Li kunyu
  2023-02-17 14:40 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Li kunyu @ 2023-02-08 19:34 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, Li kunyu

Modify the return value variable to be consistent with the return value
type of the function, and modify the initialization assignment. Under
certain circumstances, the constant return value is not required.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 fs/ext4/extents.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9de1c9d1a13d..debeb2e7a162 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4676,7 +4676,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	struct inode *inode = file_inode(file);
 	loff_t new_size = 0;
 	unsigned int max_blocks;
-	int ret = 0;
+	long ret = -EOPNOTSUPP;
 	int flags;
 	ext4_lblk_t lblk;
 	unsigned int blkbits = inode->i_blkbits;
@@ -4689,13 +4689,13 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	 */
 	if (IS_ENCRYPTED(inode) &&
 	    (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
-		return -EOPNOTSUPP;
+		return ret;
 
 	/* Return error if mode is not supported */
 	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
 		     FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
 		     FALLOC_FL_INSERT_RANGE))
-		return -EOPNOTSUPP;
+		return ret;
 
 	inode_lock(inode);
 	ret = ext4_convert_inline_data(inode);
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: extents: Modify the return value variable type and initialize the assignment
  2023-02-08 19:34 [PATCH] ext4: extents: Modify the return value variable type and initialize the assignment Li kunyu
@ 2023-02-17 14:40 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2023-02-17 14:40 UTC (permalink / raw)
  To: Li kunyu; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

On Thu 09-02-23 03:34:43, Li kunyu wrote:
> Modify the return value variable to be consistent with the return value
> type of the function, and modify the initialization assignment. Under
> certain circumstances, the constant return value is not required.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>

Hum, I don't think this really improves anything. All the functions seem to
return 0 or error code (and ext4_fallocate()) as well so the size of return
value does not really matter and we usually just use int in this case.

								Honza

> ---
>  fs/ext4/extents.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 9de1c9d1a13d..debeb2e7a162 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4676,7 +4676,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>  	struct inode *inode = file_inode(file);
>  	loff_t new_size = 0;
>  	unsigned int max_blocks;
> -	int ret = 0;
> +	long ret = -EOPNOTSUPP;
>  	int flags;
>  	ext4_lblk_t lblk;
>  	unsigned int blkbits = inode->i_blkbits;
> @@ -4689,13 +4689,13 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>  	 */
>  	if (IS_ENCRYPTED(inode) &&
>  	    (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
> -		return -EOPNOTSUPP;
> +		return ret;
>  
>  	/* Return error if mode is not supported */
>  	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
>  		     FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
>  		     FALLOC_FL_INSERT_RANGE))
> -		return -EOPNOTSUPP;
> +		return ret;
>  
>  	inode_lock(inode);
>  	ret = ext4_convert_inline_data(inode);
> -- 
> 2.18.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-17 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-08 19:34 [PATCH] ext4: extents: Modify the return value variable type and initialize the assignment Li kunyu
2023-02-17 14:40 ` Jan Kara

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 read-only IMAP folder(s) and NNTP newsgroup(s).