mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/udf: Change the type of blocksize from 'int' to 'unsigned int' in udf_discard_prealloc
@ 2023-07-07 11:07 Lu Hongfei
  2023-07-07 12:19 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Lu Hongfei @ 2023-07-07 11:07 UTC (permalink / raw)
  To: Jan Kara, linux-kernel; +Cc: opensource.kernel, luhongfei

The return value type of i_blocksize() is 'unsigned int', so the
type of blocksize has been modified from 'int' to 'unsigned int'
to ensure data type consistency.

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
 fs/udf/truncate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index a686c10fd709..c80dfcc583f6 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -123,7 +123,7 @@ void udf_discard_prealloc(struct inode *inode)
 	uint64_t lbcount = 0;
 	int8_t etype = -1;
 	struct udf_inode_info *iinfo = UDF_I(inode);
-	int bsize = i_blocksize(inode);
+	unsigned int bsize = i_blocksize(inode);
 
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ||
 	    ALIGN(inode->i_size, bsize) == ALIGN(iinfo->i_lenExtents, bsize))
-- 
2.39.0


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

* Re: [PATCH] fs/udf: Change the type of blocksize from 'int' to 'unsigned int' in udf_discard_prealloc
  2023-07-07 11:07 [PATCH] fs/udf: Change the type of blocksize from 'int' to 'unsigned int' in udf_discard_prealloc Lu Hongfei
@ 2023-07-07 12:19 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2023-07-07 12:19 UTC (permalink / raw)
  To: Lu Hongfei; +Cc: Jan Kara, linux-kernel, opensource.kernel

On Fri 07-07-23 19:07:52, Lu Hongfei wrote:
> The return value type of i_blocksize() is 'unsigned int', so the
> type of blocksize has been modified from 'int' to 'unsigned int'
> to ensure data type consistency.
> 
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>

Thanks for the patch but I'm sorry but how does this make a difference?
Blocksize is a small positive integer (512-64k). So it doesn't matter
whether you store it in int or unsigned it. I agree sometimes there are
nasty issues in C with signed comparisons, sign extension and other complex
logic and there it is beneficial to really be sure to match signedness etc.
to avoid subtle issues. But in this particular case I don't see the
point so I'd just keep the code as is... But please tell me if you see some
readability or other benefit in this change.

								Honza

> ---
>  fs/udf/truncate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
> index a686c10fd709..c80dfcc583f6 100644
> --- a/fs/udf/truncate.c
> +++ b/fs/udf/truncate.c
> @@ -123,7 +123,7 @@ void udf_discard_prealloc(struct inode *inode)
>  	uint64_t lbcount = 0;
>  	int8_t etype = -1;
>  	struct udf_inode_info *iinfo = UDF_I(inode);
> -	int bsize = i_blocksize(inode);
> +	unsigned int bsize = i_blocksize(inode);
>  
>  	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ||
>  	    ALIGN(inode->i_size, bsize) == ALIGN(iinfo->i_lenExtents, bsize))
> -- 
> 2.39.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2023-07-07 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-07 11:07 [PATCH] fs/udf: Change the type of blocksize from 'int' to 'unsigned int' in udf_discard_prealloc Lu Hongfei
2023-07-07 12:19 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®