LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH linux-next] fs/ext4: use BUG_ON instead of if condition followed by BUG
@ 2021-12-19 13:06 cgel.zte
  2021-12-20 10:24 ` Lukas Czerner
  0 siblings, 1 reply; 6+ messages in thread
From: cgel.zte @ 2021-12-19 13:06 UTC (permalink / raw
  To: tytso, linux-ext4; +Cc: adilger.kernel, linux-kernel, xu xin, Zeal robot

From: xu xin <xu.xin16@zte.com.cn>

BUG_ON would be better.

This issue was detected with the help of Coccinelle.

Reported-by: Zeal robot <zealci@zte.com.cn>
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
 fs/ext4/ext4.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9cc55bcda6ba..00bc3f67d37f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
 
 static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
 {
-	if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
-		BUG();
+	BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
 #if (PAGE_SIZE >= 65536)
 	if (len < 65536)
 		return cpu_to_le16(len);
-- 
2.25.1


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

* Re: [PATCH linux-next] fs/ext4: use BUG_ON instead of if condition followed by BUG
  2021-12-19 13:06 [PATCH linux-next] fs/ext4: use BUG_ON instead of if condition followed by BUG cgel.zte
@ 2021-12-20 10:24 ` Lukas Czerner
  2021-12-28  7:32   ` [PATCH resend] " cgel.zte
  0 siblings, 1 reply; 6+ messages in thread
From: Lukas Czerner @ 2021-12-20 10:24 UTC (permalink / raw
  To: cgel.zte
  Cc: tytso, linux-ext4, adilger.kernel, linux-kernel, xu xin,
	Zeal robot

On Sun, Dec 19, 2021 at 01:06:43PM +0000, cgel.zte@gmail.com wrote:
> From: xu xin <xu.xin16@zte.com.cn>
> 
> BUG_ON would be better.

Indeed. Thanks for the patch.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>


> 
> This issue was detected with the help of Coccinelle.
> 
> Reported-by: Zeal robot <zealci@zte.com.cn>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
>  fs/ext4/ext4.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 9cc55bcda6ba..00bc3f67d37f 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
>  
>  static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
>  {
> -	if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
> -		BUG();
> +	BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
>  #if (PAGE_SIZE >= 65536)
>  	if (len < 65536)
>  		return cpu_to_le16(len);
> -- 
> 2.25.1
> 


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

* [PATCH resend] fs/ext4: use BUG_ON instead of if condition followed by BUG
  2021-12-20 10:24 ` Lukas Czerner
@ 2021-12-28  7:32   ` cgel.zte
  2022-01-05  5:35     ` riteshh
  2022-01-06  4:41     ` Theodore Ts'o
  0 siblings, 2 replies; 6+ messages in thread
From: cgel.zte @ 2021-12-28  7:32 UTC (permalink / raw
  To: lczerner
  Cc: adilger.kernel, cgel.zte, linux-ext4, linux-kernel, tytso,
	xu.xin16, zealci

From: xu xin <xu.xin16@zte.com.cn>

BUG_ON would be better.

This issue was detected with the help of Coccinelle.

Reported-by: Zeal robot <zealci@zte.com.cn>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
 fs/ext4/ext4.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9cc55bcda6ba..00bc3f67d37f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
 
 static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
 {
-	if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
-		BUG();
+	BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
 #if (PAGE_SIZE >= 65536)
 	if (len < 65536)
 		return cpu_to_le16(len);
-- 
2.25.1


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

* Re: [PATCH resend] fs/ext4: use BUG_ON instead of if condition followed by BUG
  2021-12-28  7:32   ` [PATCH resend] " cgel.zte
@ 2022-01-05  5:35     ` riteshh
  2022-01-05  6:22       ` cgel.zte
  2022-01-06  4:41     ` Theodore Ts'o
  1 sibling, 1 reply; 6+ messages in thread
From: riteshh @ 2022-01-05  5:35 UTC (permalink / raw
  To: cgel.zte
  Cc: lczerner, adilger.kernel, linux-ext4, linux-kernel, tytso,
	xu.xin16, zealci

On 21/12/28 07:32AM, cgel.zte@gmail.com wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> BUG_ON would be better.

While we are at it, I feel correcting below BUG() in the same patch(es?)
might be useful too.

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bfd3545f1e5d..5656b4a9007b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1879,10 +1879,7 @@ static int __ext4_journalled_writepage(struct page *page,
                        goto out;
        } else {
                page_bufs = page_buffers(page);
-               if (!page_bufs) {
-                       BUG();
-                       goto out;
-               }
+               BUG_ON(!page_bufs);
                ext4_walk_page_buffers(handle, inode, page_bufs, 0, len,
                                       NULL, bget_one);
        }

-riteshh

>
> This issue was detected with the help of Coccinelle.
>
> Reported-by: Zeal robot <zealci@zte.com.cn>
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
>  fs/ext4/ext4.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 9cc55bcda6ba..00bc3f67d37f 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
>
>  static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
>  {
> -	if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
> -		BUG();
> +	BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
>  #if (PAGE_SIZE >= 65536)
>  	if (len < 65536)
>  		return cpu_to_le16(len);
> --
> 2.25.1
>

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

* Re: [PATCH resend] fs/ext4: use BUG_ON instead of if condition followed by BUG
  2022-01-05  5:35     ` riteshh
@ 2022-01-05  6:22       ` cgel.zte
  0 siblings, 0 replies; 6+ messages in thread
From: cgel.zte @ 2022-01-05  6:22 UTC (permalink / raw
  To: riteshh
  Cc: adilger.kernel, cgel.zte, lczerner, linux-ext4, linux-kernel,
	tytso, xu.xin16, zealci

>While we are at it, I feel correcting below BUG() in the same patch(es?)
>might be useful too.

I agree with it.

Feel free if you're willing to do the integration of patches.




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

* Re: [PATCH resend] fs/ext4: use BUG_ON instead of if condition followed by BUG
  2021-12-28  7:32   ` [PATCH resend] " cgel.zte
  2022-01-05  5:35     ` riteshh
@ 2022-01-06  4:41     ` Theodore Ts'o
  1 sibling, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2022-01-06  4:41 UTC (permalink / raw
  To: cgel.zte
  Cc: lczerner, adilger.kernel, linux-ext4, linux-kernel, xu.xin16,
	zealci

On Tue, Dec 28, 2021 at 07:32:52AM +0000, cgel.zte@gmail.com wrote:
> From: xu xin <xu.xin16@zte.com.cn>
> 
> BUG_ON would be better.
> 
> This issue was detected with the help of Coccinelle.
> 
> Reported-by: Zeal robot <zealci@zte.com.cn>
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2022-01-06  4:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-19 13:06 [PATCH linux-next] fs/ext4: use BUG_ON instead of if condition followed by BUG cgel.zte
2021-12-20 10:24 ` Lukas Czerner
2021-12-28  7:32   ` [PATCH resend] " cgel.zte
2022-01-05  5:35     ` riteshh
2022-01-05  6:22       ` cgel.zte
2022-01-06  4:41     ` Theodore Ts'o

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