linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcachefs: Use int type to store negative error codes
@ 2025-08-30 13:58 Qianfeng Rong
  2025-09-01 22:38 ` Kent Overstreet
  0 siblings, 1 reply; 2+ messages in thread
From: Qianfeng Rong @ 2025-08-30 13:58 UTC (permalink / raw)
  To: Kent Overstreet, linux-bcachefs, linux-kernel; +Cc: Qianfeng Rong

Change the 'ret' variable in __bch2_dev_attach_bdev() from unsigned to
int, as it needs to store either negative error codes or zero.

Storing the negative error codes in unsigned type, doesn't cause an issue
at runtime but can be confusing. Additionally, assigning negative error
codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
flag is enabled.

No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 fs/bcachefs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 793c16fa8b09..ec20ab0ad84e 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1769,7 +1769,7 @@ static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx)
 static int __bch2_dev_attach_bdev(struct bch_dev *ca, struct bch_sb_handle *sb,
 				  struct printbuf *err)
 {
-	unsigned ret;
+	int ret;
 
 	if (bch2_dev_is_online(ca)) {
 		prt_printf(err, "already have device online in slot %u\n",
-- 
2.34.1


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

* Re: [PATCH] bcachefs: Use int type to store negative error codes
  2025-08-30 13:58 [PATCH] bcachefs: Use int type to store negative error codes Qianfeng Rong
@ 2025-09-01 22:38 ` Kent Overstreet
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Overstreet @ 2025-09-01 22:38 UTC (permalink / raw)
  To: Qianfeng Rong; +Cc: linux-bcachefs, linux-kernel

On Sat, Aug 30, 2025 at 09:58:33PM +0800, Qianfeng Rong wrote:
> Change the 'ret' variable in __bch2_dev_attach_bdev() from unsigned to
> int, as it needs to store either negative error codes or zero.
> 
> Storing the negative error codes in unsigned type, doesn't cause an issue
> at runtime but can be confusing. Additionally, assigning negative error
> codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
> flag is enabled.
> 
> No effect on runtime.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>

Thanks, applied

> ---
>  fs/bcachefs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
> index 793c16fa8b09..ec20ab0ad84e 100644
> --- a/fs/bcachefs/super.c
> +++ b/fs/bcachefs/super.c
> @@ -1769,7 +1769,7 @@ static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx)
>  static int __bch2_dev_attach_bdev(struct bch_dev *ca, struct bch_sb_handle *sb,
>  				  struct printbuf *err)
>  {
> -	unsigned ret;
> +	int ret;
>  
>  	if (bch2_dev_is_online(ca)) {
>  		prt_printf(err, "already have device online in slot %u\n",
> -- 
> 2.34.1
> 

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

end of thread, other threads:[~2025-09-01 22:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30 13:58 [PATCH] bcachefs: Use int type to store negative error codes Qianfeng Rong
2025-09-01 22:38 ` Kent Overstreet

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).